@@ -13,7 +13,6 @@ import isEqual from 'lodash-es/isEqual';
13
13
import type { Options } from 'scroll-into-view-if-needed' ;
14
14
import scrollIntoView from 'scroll-into-view-if-needed' ;
15
15
import initDefaultProps from '../_util/props-util/initDefaultProps' ;
16
- import type { VueNode } from '../_util/type' ;
17
16
import { tuple } from '../_util/type' ;
18
17
import type { ColProps } from '../grid/Col' ;
19
18
import type {
@@ -24,6 +23,7 @@ import type {
24
23
ValidateOptions ,
25
24
Callbacks ,
26
25
ValidateMessages ,
26
+ Rule ,
27
27
} from './interface' ;
28
28
import { useInjectSize } from '../_util/hooks/useSize' ;
29
29
import useConfigInject from '../_util/hooks/useConfigInject' ;
@@ -34,32 +34,8 @@ import useForm from './useForm';
34
34
export type RequiredMark = boolean | 'optional' ;
35
35
export type FormLayout = 'horizontal' | 'inline' | 'vertical' ;
36
36
37
- export type ValidationRule = {
38
- /** validation error message */
39
- message ?: VueNode ;
40
- /** built-in validation type, available options: https://github.com/yiminghe/async-validator#type */
41
- type ?: string ;
42
- /** indicates whether field is required */
43
- required ?: boolean ;
44
- /** treat required fields that only contain whitespace as errors */
45
- whitespace ?: boolean ;
46
- /** validate the exact length of a field */
47
- len ?: number ;
48
- /** validate the min length of a field */
49
- min ?: number ;
50
- /** validate the max length of a field */
51
- max ?: number ;
52
- /** validate the value from a list of possible values */
53
- enum ?: string | string [ ] ;
54
- /** validate from a regular expression */
55
- pattern ?: RegExp ;
56
- /** transform a value before validation */
57
- transform ?: ( value : any ) => any ;
58
- /** custom validate function (Note: callback must be called) */
59
- validator ?: ( rule : any , value : any , callback : any , source ?: any , options ?: any ) => any ;
60
-
61
- trigger ?: string ;
62
- } ;
37
+ /** @deprecated Will warning in future branch. Pls use `Rule` instead. */
38
+ export type ValidationRule = Rule ;
63
39
64
40
export const formProps = ( ) => ( {
65
41
layout : PropTypes . oneOf ( tuple ( 'horizontal' , 'inline' , 'vertical' ) ) ,
@@ -73,7 +49,7 @@ export const formProps = () => ({
73
49
/** @deprecated Will warning in future branch. Pls use `requiredMark` instead. */
74
50
hideRequiredMark : { type : Boolean , default : undefined } ,
75
51
model : PropTypes . object ,
76
- rules : { type : Object as PropType < { [ k : string ] : ValidationRule [ ] | ValidationRule } > } ,
52
+ rules : { type : Object as PropType < { [ k : string ] : Rule [ ] | Rule } > } ,
77
53
validateMessages : {
78
54
type : Object as PropType < ValidateMessages > ,
79
55
default : undefined as ValidateMessages ,
0 commit comments