@@ -25,14 +25,12 @@ export const errors = {
2525 `onSubmit must be a function, but it was ${ typeof onSubmit } .` ,
2626 'docs: https://github.com/balazsorban44/use-form/wiki#use-form-onSubmit' ,
2727 ] . join ( '\n' ) ,
28-
2928 validators : validators => [
3029 `validators must be a function, but it was ${ typeof validators } .` ,
3130 'docs: https://github.com/balazsorban44/use-form/wiki#use-form-validators' ,
3231 ] . join ( '\n' ) ,
33-
34- validator : keys => [
35- `The validator(s) for ${ keys } in validators are invalid.` ,
32+ invalidValidators : ( keys ) => [
33+ `The following validator(s) were invalid: ${ keys } ` ,
3634 'docs: https://github.com/balazsorban44/use-form/wiki#use-form-validators' ,
3735 ] . join ( '\n' ) ,
3836 outsideProvider : name => `useForm with name cannot be used outside a FormProvider (name was ${ name } )`
@@ -50,17 +48,9 @@ export default function handleDevErrors ({ name, initialState, form, validators,
5048 if ( ! form )
5149 throw new Error ( errors . initialState ( name ) )
5250
53- if ( typeof validators !== 'function' ) {
51+ if ( typeof validators !== 'function' )
5452 throw new TypeError ( errors . validators ( validators ) )
5553
56- } else {
57- const invalidValidators = Object . keys ( form ) . filter ( key =>
58- typeof validators ( form , false ) [ key ] !== 'boolean'
59- )
60- if ( invalidValidators . length )
61- throw new TypeError ( errors . validator ( invalidValidators ) )
62- }
63-
6454 if ( typeof onSubmit !== 'function' )
6555 throw new TypeError ( errors . onSubmit ( onSubmit ) )
6656}
0 commit comments