1
- import { FormItemRule } from " element-plus" ;
2
- import { FieldDefault , FieldSelection , Formkl } from " formkl" ;
3
- import { isValueValidated } from "@formkl/ utils" ;
1
+ import { FormItemRule } from ' element-plus' ;
2
+ import { FieldDefault , FieldSelection , Formkl } from ' formkl' ;
3
+ import { isValueValidated } from '../../../../../ utils/src' ;
4
4
5
5
export class Rule {
6
6
private _formkl : Formkl ;
@@ -18,27 +18,27 @@ export class Rule {
18
18
if ( this . _field . require ) {
19
19
this . _rules . push ( {
20
20
required : true ,
21
- message : this . _field . label + " field is required" ,
21
+ message : this . _field . label + ' field is required' ,
22
22
} ) ;
23
23
}
24
24
}
25
25
26
26
private _buildTypeRule ( ) {
27
27
switch ( this . _field . type ) {
28
- case " number" :
29
- case " text" :
30
- case " paragraph" :
28
+ case ' number' :
29
+ case ' text' :
30
+ case ' paragraph' :
31
31
this . _rules . push ( {
32
- type : this . _field . type === " number" ? " number" : " string" ,
32
+ type : this . _field . type === ' number' ? ' number' : ' string' ,
33
33
message : `${ this . _field . label } field must be a ${ this . _field . type } !` ,
34
34
} ) ;
35
35
break ;
36
- case " time" :
37
- case " date" :
38
- case " datetime" :
36
+ case ' time' :
37
+ case ' date' :
38
+ case ' datetime' :
39
39
this . _rules . push ( {
40
- type : " date" ,
41
- message : this . _field . label + " field must be a valid time!" ,
40
+ type : ' date' ,
41
+ message : this . _field . label + ' field must be a valid time!' ,
42
42
} ) ;
43
43
break ;
44
44
@@ -53,7 +53,7 @@ export class Rule {
53
53
validator : ( rule , value , callback ) => {
54
54
const errors : Error [ ] = [ ] ;
55
55
if ( value && this . _field . validation && ! isValueValidated ( value , this . _field . validation ) ) {
56
- errors . push ( new Error ( " Field is invalid" ) ) ;
56
+ errors . push ( new Error ( ' Field is invalid' ) ) ;
57
57
}
58
58
59
59
return errors ;
0 commit comments