Browse Source

chore(nc-gui): replace isEmail with validateEmail

pull/3847/head
braks 2 years ago
parent
commit
e46b5fad94
  1. 4
      packages/nc-gui/components/cell/Email.vue
  2. 4
      packages/nc-gui/components/tabs/auth/user-management/UsersModal.vue
  3. 4
      packages/nc-gui/pages/forgot-password.vue
  4. 4
      packages/nc-gui/pages/signin.vue
  5. 15
      packages/nc-gui/pages/signup/[[token]].vue

4
packages/nc-gui/components/cell/Email.vue

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core'
import { EditModeInj, computed, inject, isEmail, useVModel } from '#imports'
import { EditModeInj, computed, inject, useVModel, validateEmail } from '#imports'
interface Props {
modelValue: string | null | undefined
@ -18,7 +18,7 @@ const editEnabled = inject(EditModeInj)
const vModel = useVModel(props, 'modelValue', emits)
const validEmail = computed(() => vModel.value && isEmail(vModel.value))
const validEmail = computed(() => vModel.value && validateEmail(vModel.value))
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
</script>

4
packages/nc-gui/components/tabs/auth/user-management/UsersModal.vue

@ -3,7 +3,6 @@ import {
Form,
computed,
extractSdkResponseErrorMsg,
isEmail,
message,
onMounted,
projectRoleTagColors,
@ -14,6 +13,7 @@ import {
useI18n,
useNuxtApp,
useProject,
validateEmail,
} from '#imports'
import type { User } from '~/lib'
import { ProjectRole } from '~/lib'
@ -57,7 +57,7 @@ const validators = computed(() => {
callback('Email is required')
return
}
const invalidEmails = (value || '').split(/\s*,\s*/).filter((e: string) => !isEmail(e))
const invalidEmails = (value || '').split(/\s*,\s*/).filter((e: string) => !validateEmail(e))
if (invalidEmails.length > 0) {
callback(`${invalidEmails.length > 1 ? ' Invalid emails:' : 'Invalid email:'} ${invalidEmails.join(', ')} `)
} else {

4
packages/nc-gui/pages/forgot-password.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import { definePageMeta, isEmail, reactive, ref, useApi, useI18n } from '#imports'
import { definePageMeta, reactive, ref, useApi, useI18n, validateEmail } from '#imports'
definePageMeta({
requiresAuth: false,
@ -25,7 +25,7 @@ const formRules = {
{
validator: (_: unknown, v: string) => {
return new Promise((resolve, reject) => {
if (isEmail(v)) return resolve(true)
if (validateEmail(v)) return resolve(true)
reject(new Error(t('msg.error.signUpRules.emailInvalid')))
})
},

4
packages/nc-gui/pages/signin.vue

@ -1,6 +1,6 @@
<script setup lang="ts">
import type { RuleObject } from 'ant-design-vue/es/form'
import { definePageMeta, isEmail, navigateTo, reactive, ref, useApi, useGlobal, useI18n, useSidebar } from '#imports'
import { definePageMeta, navigateTo, reactive, ref, useApi, useGlobal, useI18n, useSidebar, validateEmail } from '#imports'
definePageMeta({
requiresAuth: false,
@ -30,7 +30,7 @@ const formRules: Record<string, RuleObject[]> = {
{
validator: (_: unknown, v: string) => {
return new Promise((resolve, reject) => {
if (isEmail(v)) return resolve()
if (validateEmail(v)) return resolve()
reject(new Error(t('msg.error.signUpRules.emailInvalid')))
})

15
packages/nc-gui/pages/signup/[[token]].vue

@ -1,6 +1,17 @@
<script setup lang="ts">
import { validatePassword } from 'nocodb-sdk'
import { definePageMeta, isEmail, navigateTo, reactive, ref, useApi, useGlobal, useI18n, useNuxtApp, useRoute } from '#imports'
import {
definePageMeta,
navigateTo,
reactive,
ref,
useApi,
useGlobal,
useI18n,
useNuxtApp,
useRoute,
validateEmail,
} from '#imports'
definePageMeta({
requiresAuth: false,
@ -33,7 +44,7 @@ const formRules = {
{
validator: (_: unknown, v: string) => {
return new Promise((resolve, reject) => {
if (!v?.length || isEmail(v)) return resolve(true)
if (!v?.length || validateEmail(v)) return resolve(true)
reject(new Error(t('msg.error.signUpRules.emailInvalid')))
})
},

Loading…
Cancel
Save