@@ -10,6 +10,7 @@ export interface Action {
1010}
1111
1212export type ValidationResponse = string | true ;
13+ export type Validator < T > = ( value : T ) => ValidationResponse ;
1314
1415export type InputForm < T extends object > = {
1516 [ P in keyof T ] : FormPromise < T [ P ] > ;
@@ -28,35 +29,31 @@ export interface InputOutput {
2829 helperText ?: string ;
2930 placeholder ?: string ;
3031 type ?: 'text' | 'password' | 'email' ;
31- validation ?: ( value : string ) => ValidationResponse ;
32+ validation ?: Validator < string > ;
3233 } ) : FormPromise < string > ;
33- number ( opts : {
34- label : string ;
35- helperText ?: string ;
36- validation ?: ( value : number ) => ValidationResponse ;
37- } ) : FormPromise < number > ;
34+ number ( opts : { label : string ; helperText ?: string ; validation ?: Validator < number > } ) : FormPromise < number > ;
3835 } ;
3936 select : {
4037 radio < T > ( opts : {
4138 label : string ;
4239 helperText ?: string ;
43- validation ?: ( value : string ) => ValidationResponse ;
40+ validation ?: Validator < T > ;
4441 data : T [ ] ;
4542 getLabel : ( item : T ) => string ;
4643 getValue : ( item : T ) => string ;
4744 } ) : FormPromise < T > ;
4845 dropdown < T > ( opts : {
4946 label : string ;
5047 helperText ?: string ;
51- validation ?: ( value : string ) => ValidationResponse ;
48+ validation ?: Validator < T > ;
5249 data : T [ ] ;
5350 getLabel : ( item : T ) => string ;
5451 getValue : ( item : T ) => string ;
5552 } ) : FormPromise < T > ;
5653 table < T > ( opts : {
5754 label : string ;
5855 helperText ?: string ;
59- validation ?: ( value : string ) => ValidationResponse ;
56+ validation ?: Validator < T > ;
6057 data : T [ ] ;
6158 headers : string [ ] ;
6259 initialSelection ?: string ;
@@ -68,23 +65,23 @@ export interface InputOutput {
6865 checkbox < T > ( opts : {
6966 label : string ;
7067 helperText ?: string ;
71- validation ?: ( value : string ) => ValidationResponse ;
68+ validation ?: Validator < T [ ] > ;
7269 data : T [ ] ;
7370 getLabel : ( item : T ) => string ;
7471 getValue : ( item : T ) => string ;
7572 } ) : FormPromise < T [ ] > ;
7673 dropdown < T > ( opts : {
7774 label : string ;
7875 helperText ?: string ;
79- validation ?: ( value : string ) => ValidationResponse ;
76+ validation ?: Validator < T [ ] > ;
8077 data : T [ ] ;
8178 getLabel : ( item : T ) => string ;
8279 getValue : ( item : T ) => string ;
8380 } ) : FormPromise < T [ ] > ;
8481 table < T > ( opts : {
8582 label : string ;
8683 helperText ?: string ;
87- validation ?: ( value : string ) => ValidationResponse ;
84+ validation ?: Validator < T [ ] > ;
8885 data : T [ ] ;
8986 headers : string [ ] ;
9087 initialSelection ?: string [ ] ;
0 commit comments