@@ -169,7 +169,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
169
169
/**
170
170
* Create a debounced validation callback.
171
171
*/
172
- const createValidator = ( ) => debounce ( ( instanceConfig : Config ) => {
172
+ const createValidator = ( ) => debounce ( ( instanceConfig : ValidationConfig ) => {
173
173
callback ( {
174
174
get : ( url , data = { } , globalConfig = { } ) => client . get ( url , parseData ( data ) , resolveConfig ( globalConfig , instanceConfig , data ) ) ,
175
175
post : ( url , data = { } , globalConfig = { } ) => client . post ( url , parseData ( data ) , resolveConfig ( globalConfig , instanceConfig , data ) ) ,
@@ -254,11 +254,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
254
254
: response
255
255
} ,
256
256
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 ) {
262
258
return false
263
259
}
264
260
@@ -296,7 +292,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
296
292
/**
297
293
* Validate the given input.
298
294
*/
299
- const validate = ( name ?: string | NamedInputEvent , value ?: unknown , config ?: Config ) : void => {
295
+ const validate = ( name ?: string | NamedInputEvent , value ?: unknown , config ?: ValidationConfig ) : void => {
300
296
if ( typeof name === 'undefined' ) {
301
297
validator ( config ?? { } )
302
298
@@ -313,9 +309,9 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
313
309
314
310
if ( get ( oldData , name ) !== value ) {
315
311
setTouched ( [ name , ...touched ] ) . forEach ( ( listener ) => listener ( ) )
316
- }
317
312
318
- validator ( config ?? { } )
313
+ validator ( config ?? { } )
314
+ }
319
315
}
320
316
321
317
/**
0 commit comments