File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed
Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ type FieldsDescription = {
1010 [ key : string ] : RuleData | RuleData [ ] ;
1111} ;
1212
13+ type updaterFunction < T > = ( prevState : Readonly < T > ) => T ;
14+
1315export default class Validator < State > {
1416 constructor ( fields : FieldsDescription , validationStorageName ?: string ) ;
1517
@@ -25,18 +27,14 @@ export default class Validator<State> {
2527 addValidation ( state : State , showErrorsOnStart ?: boolean ) : Readonly < State > ;
2628
2729 validate (
28- stateUpdates : ( prevState : Readonly < State > ) => State ,
30+ stateUpdates ?: Partial < State > | updaterFunction < State > | null ,
2931 showErrors ?: boolean
3032 ) : ( ( prevState : Readonly < State > ) => State ) ;
3133
32- validate (
33- stateUpdates ?: { [ key in keyof State ] : any } | null ,
34- showErrors ?: boolean
35- ) : Readonly < State > ;
36-
37- getErrors ( state : State ) : { [ key in keyof State ] : any } ;
34+ getErrors ( state : State ) : { [ key in keyof State ] : string } ;
3835
3936 isFormValid ( state : State ) : boolean ;
4037
4138 isFieldValid ( state : State , fieldName : string ) : boolean ;
4239}
40+
Original file line number Diff line number Diff line change 11{
22 "name" : " react-validation-utils" ,
3- "version" : " 1.3.6 " ,
3+ "version" : " 1.3.7 " ,
44 "description" : " Validate react form components, based on their state" ,
55 "main" : " build/index.js" ,
66 "types" : " build/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ type FieldsDescription = {
1010 [ key : string ] : RuleData | RuleData [ ] ;
1111} ;
1212
13+ type updaterFunction < T > = ( prevState : Readonly < T > ) => T ;
14+
1315export default class Validator < State > {
1416 constructor ( fields : FieldsDescription , validationStorageName ?: string ) ;
1517
@@ -25,18 +27,14 @@ export default class Validator<State> {
2527 addValidation ( state : State , showErrorsOnStart ?: boolean ) : Readonly < State > ;
2628
2729 validate (
28- stateUpdates : ( prevState : Readonly < State > ) => State ,
30+ stateUpdates ?: Partial < State > | updaterFunction < State > | null ,
2931 showErrors ?: boolean
3032 ) : ( ( prevState : Readonly < State > ) => State ) ;
3133
32- validate (
33- stateUpdates ?: { [ key in keyof State ] : any } | null ,
34- showErrors ?: boolean
35- ) : Readonly < State > ;
36-
37- getErrors ( state : State ) : { [ key in keyof State ] : any } ;
34+ getErrors ( state : State ) : { [ key in keyof State ] : string } ;
3835
3936 isFormValid ( state : State ) : boolean ;
4037
4138 isFieldValid ( state : State , fieldName : string ) : boolean ;
4239}
40+
You can’t perform that action at this time.
0 commit comments