From 56cbfa173f307c072e134387a45f4d7b75a2b4fd Mon Sep 17 00:00:00 2001 From: janryWang Date: Sat, 29 Jun 2019 11:52:34 +0800 Subject: [PATCH] docs(field): update field docs --- docs/API/Field_React.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/API/Field_React.md b/docs/API/Field_React.md index d14f31a43ab..ab96aebe3b2 100644 --- a/docs/API/Field_React.md +++ b/docs/API/Field_React.md @@ -20,9 +20,9 @@ import {Field} from '@uform/react' | minItems | 最小条目数,只有在type="array"时可以使用 | Number | | | | name | 字段名称 | Object | {} | | | required | 字段是否必填 | Boolean | false | | -| description | 字段描述,如果字符串字数超过20字或内容是ReactNode,会自动以pop形式展示 | String/React Node | '' | | -| type | 字段类型 | Object | | | -| x-component | 字段UI组件,用于指定该字段应该用什么组件做渲染 | Object | {type:"object",properties:{}} | | +| description | 字段描述,如果字符串字数超过30字或内容是ReactNode,会自动以pop形式展示 | String/React Node | '' | | +| type | 字段类型,具体类型枚举参考 [fields](https://github.com/alibaba/uform/tree/master/packages/antd/src/fields) | String | "" | | +| x-component | 字段UI组件,用于指定该字段应该用什么组件做渲染,具体类型枚举参考 [fields](https://github.com/alibaba/uform/tree/master/packages/antd/src/fields) | String | "" | | | x-effect | 副作用事件绑定对象 | `Function(dispatch : Function) : { [eventName](...arguemtns)}` | | | | x-index | 字段索引顺序 | Number | | | | x-props | 字段UI组件属性,API请参考对应fusion next/ant design组件API | Object | {} | | @@ -71,14 +71,23 @@ import {Field} from '@uform/react' - 自定义校验,在x-rules中可以通过传函数来描述,下面是该函数的类型描述 ```typescript -type RuleCallback( - value : any, - rule : Object, - values : Object, - name : String) : String | Promise - -该回调函数直接return错误文案字符串代表响应错误,如果返回Promise对象, -代表是异步校验,resolve错误文案的时候代表错误响应,resolve为空的时候代表正确响应 +interface IRuleDescription { + required?: boolean + message?: string, + pattern?: RegExp | string, + validator?: Validator, + format?: DefaultPatternRule +} + +type Validator = (value: any, rule: IRuleDescription, values: any, name: string) => string | Promise + +type DefaultPatternRule = 'url' | 'email' | 'ipv6' | 'ipv4' | 'number' | 'integer' | 'qq' | 'phone' | 'idcard' | 'taodomain' | 'money' | 'zh' | 'date' | 'zip' + +type Rule = Validator | Array | DefaultPatternRule | IRuleDescrip + +//该回调函数直接return错误文案字符串代表响应错误,如果返回Promise对象, +//代表是异步校验,resolve错误文案的时候代表错误响应,resolve为空的时候代表正确响应 + ``` ## x-render详解