Browse Source

refactor: validateErrorTip 重命名

xyh 2 years ago
parent
commit
407aeaf6db
3 changed files with 9 additions and 9 deletions
  1. 3 3
      src/pages/login/hooks.ts
  2. 5 5
      src/pages/register/hooks.ts
  3. 1 1
      src/utils/validate-tips/index.ts

+ 3 - 3
src/pages/login/hooks.ts

@@ -1,7 +1,7 @@
 import {object, string} from 'zod';
 import {useForm} from 'vee-validate';
 import {toTypedSchema} from '@vee-validate/zod';
-import {validateErrorTip} from '@utils';
+import {formatValidateError} from '@utils';
 
 export type FormState = {
   name: string;
@@ -18,9 +18,9 @@ export function useFormState() {
     },
     validationSchema: toTypedSchema(
       object({
-        name: string(validateErrorTip('login.errors.name'))
+        name: string(formatValidateError('login.errors.name'))
           .min(1, 'login.errors.name'),
-        password: string(validateErrorTip('login.errors.password'))
+        password: string(formatValidateError('login.errors.password'))
           .min(1, 'login.errors.password'),
         company: string().optional(),
       }),

+ 5 - 5
src/pages/register/hooks.ts

@@ -1,4 +1,4 @@
-import {validateErrorTip} from '@utils';
+import {formatValidateError} from '@utils';
 import {toTypedSchema} from '@vee-validate/zod';
 import {useForm} from 'vee-validate';
 import {Ref} from 'vue';
@@ -20,13 +20,13 @@ export function useFormState(isSuccess: Ref<boolean>) {
       licenseImage: '',
     },
     validationSchema: toTypedSchema(object({
-      enterprise: string(validateErrorTip('register.errors.enterprise'))
+      enterprise: string(formatValidateError('register.errors.enterprise'))
         .min(1, 'register.errors.enterprise'),
-      phone: string(validateErrorTip('register.errors.phone'))
+      phone: string(formatValidateError('register.errors.phone'))
         .min(1, 'register.errors.phone'),
-      idCardImage: string(validateErrorTip('register.errors.idcard'))
+      idCardImage: string(formatValidateError('register.errors.idcard'))
         .min(1, 'register.errors.idcard'),
-      licenseImage: string(validateErrorTip('register.errors.licenseImage'))
+      licenseImage: string(formatValidateError('register.errors.licenseImage'))
         .min(1, 'register.errors.licenseImage'),
     })),
   });

+ 1 - 1
src/utils/validate-tips/index.ts

@@ -1,5 +1,5 @@
 /* eslint-disable camelcase */
-export function validateErrorTip(message: string): {
+export function formatValidateError(message: string): {
   invalid_type_error?: string | undefined;
   required_error?: string | undefined;
 } {