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
原因在于 源码中 getRulesKeys 的函数 只对key值的存在进行了校验,如果key存在那么就认为这条校验存在
getRulesKeys
import React from 'react' import { createForm } from '@formily/core' import { FormProvider,createSchemaField } from '@formily/react' import { registerValidateRules } from '@formily/validator' import { Input, FormItem, FormButtonGroup, Submit } from '@formily/antd'; // step1: 注册自定义全局校验规则 registerValidateRules({ required(e,_,ctx) { if (!e) return `${ctx.field.title}:自定义校验字段不能为空` } }) const SchemaField = createSchemaField({ components: { Input, FormItem, }, }); const form = createForm() const schema= { type: 'object', properties: { input: { type: 'string', title: '输入框', 'x-decorator': 'FormItem', 'x-component': 'Input', 'x-component-props': { style: { width: 240, }, }, 'x-validator': { required: false } }, }, }; export default () => ( <> <FormProvider form={form}> <SchemaField schema={schema} /> <FormButtonGroup> <Submit onSubmit={form.submit()}>提交</Submit> </FormButtonGroup> </FormProvider> </> )
预期是
'x-validator': { required: false }
是 false 了,应该不进行校验
@formily/[email protected]
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
原因在于 源码中
getRulesKeys
的函数 只对key值的存在进行了校验,如果key存在那么就认为这条校验存在Steps to reproduce
What is expected?
预期是
是 false 了,应该不进行校验
Package
@formily/[email protected]
The text was updated successfully, but these errors were encountered: