We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vben Admin V5
表单配置:
export const formSchamas: VbenFormProps = { wrapperClass: 'grid-cols-12', // 24栅格, commonConfig: { formItemClass: 'col-span-12', }, schema: [ { fieldName: 'notNull', label: 'notNull', // component: 'Input', component: 'InputNumber', componentProps: { placeholder: '请输入', allowClear: true, }, rules: zod.number({ required_error: '此项必填', invalid_type_error: '数据类型错误', }), formItemClass: 'col-span-4', } ] }
问: 有没有办法,使得删除填写的值后,校验提示为“此项必填”.
最新版
The text was updated successfully, but these errors were encountered:
zod .number({ invalid_type_error: '类型错误' }) .nullish() .refine((value) => value !== undefined && value !== null, { message: '字段必填', }),
这个问题在于antd的input-number组件删除所有内容后,值会变为null而不是undefined。zod校验时null不会视为未填写(undefined),所以可能得自行对必填进行验证。这里用nullish指示它允许null和undefined类型,之后用refine自行校验
Sorry, something went wrong.
No branches or pull requests
Version
Vben Admin V5
Describe the bug?
表单配置:
问:
有没有办法,使得删除填写的值后,校验提示为“此项必填”.
System Info
Relevant log output
Validations
The text was updated successfully, but these errors were encountered: