Browse Source

Revert "fix: Minor fix on ValidationRule to match AsyncValidator (#21250)" (#21391)

This reverts commit f7e7ce9d4f.
pull/21406/head
偏右 5 years ago
committed by GitHub
parent
commit
ac63d26f88
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      components/form/Form.tsx
  2. 2
      components/form/index.en-US.md
  3. 2
      components/form/index.zh-CN.md

23
components/form/Form.tsx

@ -29,7 +29,7 @@ export interface FormCreateOption<T> {
}
const FormLayouts = tuple('horizontal', 'inline', 'vertical');
export type FormLayout = typeof FormLayouts[number];
export type FormLayout = (typeof FormLayouts)[number];
export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
layout?: FormLayout;
@ -51,28 +51,11 @@ export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
labelAlign?: FormLabelAlign;
}
export type ValidationRuleType =
| 'string'
| 'number'
| 'boolean'
| 'method'
| 'regexp'
| 'integer'
| 'float'
| 'array'
| 'object'
| 'enum'
| 'date'
| 'url'
| 'hex'
| 'email'
| 'any';
export type ValidationRule = {
/** validation error message */
message?: React.ReactNode;
/** built-in validation type, available options: https://github.com/yiminghe/async-validator#type */
type?: ValidationRuleType;
type?: string;
/** indicates whether field is required */
required?: boolean;
/** treat required fields that only contain whitespace as errors */
@ -84,7 +67,7 @@ export type ValidationRule = {
/** validate the max length of a field */
max?: number;
/** validate the value from a list of possible values */
enum?: (string | number | boolean)[];
enum?: string | string[];
/** validate from a regular expression */
pattern?: RegExp;
/** transform a value before validation */

2
components/form/index.en-US.md

@ -210,7 +210,7 @@ Note: if Form.Item has multiple children that had been decorated by `getFieldDec
| Property | Description | Type | Default Value | Version |
| --- | --- | --- | --- | --- |
| enum | validate a value from a list of possible values | string[] | - | |
| enum | validate a value from a list of possible values | string | - | |
| len | validate an exact length of a field | number | - | |
| max | validate a max length of a field | number | - | |
| message | validation error message | string\|ReactNode | - | |

2
components/form/index.zh-CN.md

@ -212,7 +212,7 @@ validateFields(['field1', 'field2'], options, (errors, values) => {
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| enum | 枚举类型 | string[] | - | |
| enum | 枚举类型 | string | - | |
| len | 字段长度 | number | - | |
| max | 最大长度 | number | - | |
| message | 校验文案 | string\|ReactNode | - | |

Loading…
Cancel
Save