File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change 1
1
import { expect , it } from "vitest" ;
2
2
import { Equal , Expect } from "../helpers/type-utils" ;
3
3
4
- type ValidatorsBase = Record < string , ( value : string ) => string | void > ;
5
-
6
- type ValidatorConfig < ValidatorKey > = Record < string , Array < ValidatorKey > > ;
7
-
8
4
const makeFormValidatorFactory =
9
- < TValidators extends ValidatorsBase > ( validators : TValidators ) =>
10
- < TInput extends ValidatorConfig < keyof TValidators > > ( config : TInput ) => {
11
- return (
12
- values : Record < keyof TInput , string >
13
- ) : Record < keyof TInput , string | undefined > => {
14
- const errors = { } as any ;
5
+ < TValidatorKeys extends string > (
6
+ validators : Record < TValidatorKeys , ( value : string ) => string | void >
7
+ ) =>
8
+ < TObjKeys extends string > (
9
+ config : Record < TObjKeys , Array < TValidatorKeys > >
10
+ ) => {
11
+ return ( values : Record < TObjKeys , string > ) => {
12
+ const errors = { } as Record < TObjKeys , string | undefined > ;
15
13
16
14
for ( const key in config ) {
17
15
for ( const validator of config [ key ] ) {
You can’t perform that action at this time.
0 commit comments