fix: 校验规则

This commit is contained in:
dap 2024-10-06 09:35:53 +08:00
parent 39fbd81647
commit 37c22e4f42

View File

@ -128,15 +128,21 @@ export const drawerSchema: FormSchemaGetter = () => [
rules: z rules: z
.string() .string()
.regex(/^1[3-9]\d{9}$/, '请输入正确的手机号码') .regex(/^1[3-9]\d{9}$/, '请输入正确的手机号码')
.optional(), .optional()
.or(z.literal('')),
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'email', fieldName: 'email',
defaultValue: undefined, defaultValue: undefined,
label: '邮箱', label: '邮箱',
// TODO: 这里非必填未生效 /**
rules: z.string().email('请输入正确的邮箱').optional(), * z.literal Zod
*
* 使 z.literal
*
*/
rules: z.string().email('请输入正确的邮箱').optional().or(z.literal('')),
}, },
{ {
component: 'RadioGroup', component: 'RadioGroup',