@@ -169,7 +169,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
169169 /**
170170 * Create a debounced validation callback.
171171 */
172- const createValidator = ( ) => debounce ( ( instanceConfig : Config ) => {
172+ const createValidator = ( ) => debounce ( ( instanceConfig : ValidationConfig ) => {
173173 callback ( {
174174 get : ( url , data = { } , globalConfig = { } ) => client . get ( url , parseData ( data ) , resolveConfig ( globalConfig , instanceConfig , data ) ) ,
175175 post : ( url , data = { } , globalConfig = { } ) => client . post ( url , parseData ( data ) , resolveConfig ( globalConfig , instanceConfig , data ) ) ,
@@ -254,11 +254,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
254254 : response
255255 } ,
256256 onBefore : ( ) => {
257- const beforeValidationHandler = config . onBeforeValidation ?? ( ( newRequest , oldRequest ) => {
258- return newRequest . touched . length > 0 && ! isEqual ( newRequest , oldRequest )
259- } )
260-
261- if ( beforeValidationHandler ( { data, touched } , { data : oldData , touched : oldTouched } ) === false ) {
257+ if ( config . onBeforeValidation && config . onBeforeValidation ( { data, touched } , { data : oldData , touched : oldTouched } ) === false ) {
262258 return false
263259 }
264260
@@ -296,7 +292,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
296292 /**
297293 * Validate the given input.
298294 */
299- const validate = ( name ?: string | NamedInputEvent , value ?: unknown , config ?: Config ) : void => {
295+ const validate = ( name ?: string | NamedInputEvent , value ?: unknown , config ?: ValidationConfig ) : void => {
300296 if ( typeof name === 'undefined' ) {
301297 validator ( config ?? { } )
302298
@@ -313,9 +309,9 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
313309
314310 if ( get ( oldData , name ) !== value ) {
315311 setTouched ( [ name , ...touched ] ) . forEach ( ( listener ) => listener ( ) )
316- }
317312
318- validator ( config ?? { } )
313+ validator ( config ?? { } )
314+ }
319315 }
320316
321317 /**
0 commit comments