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
对于问题一,期待的如下:
import React from 'react' import { createForm } from '@formily/core' import { FormProvider,createSchemaField } from '@formily/react' import { registerMergeRules,registerValidateRules } from '@formily/validator' import { Input, FormItem, FormButtonGroup, Submit } from '@formily/antd'; 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: true, message: (value,context)=>{ console.log(value,context) return context.field.title + ':请输入内容' }, },] }, }, }; export default () => ( <> <FormProvider form={form}> <SchemaField schema={schema} /> <FormButtonGroup> <Submit onSubmit={form.submit()}>提交</Submit> </FormButtonGroup> </FormProvider> </> )
对于问题二,期待的如下:
import React from 'react' import { createForm } from '@formily/core' import { FormProvider,createSchemaField } from '@formily/react' import { registerMergeRules,registerValidateRules } from '@formily/validator' import { Input, FormItem, FormButtonGroup, Submit } from '@formily/antd'; 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: `{{(value,context)=>{ console.log(value,context) return "局部校验" }}}`, // required2: (value,context)=>{ // console.log(value,context) // return "局部校验2222" // } } }, }, }; export default () => ( <> <FormProvider form={form}> <SchemaField schema={schema} /> <FormButtonGroup> <Submit onSubmit={form.submit()}>提交</Submit> </FormButtonGroup> </FormProvider> </> )
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
What problem does this feature solve?
对于问题一,期待的如下:
对于问题二,期待的如下:
The text was updated successfully, but these errors were encountered: