@@ -71,7 +71,9 @@ export class ValidationExecutor {
7171 this . strictGroups = ( validatorOptions && validatorOptions . strictGroups ) || false ;
7272 this . always = ( validatorOptions && validatorOptions . always ) || false ;
7373 this . forbidUnknownValues =
74- ! validatorOptions || validatorOptions . forbidUnknownValues === undefined || validatorOptions . forbidUnknownValues !== false ;
74+ ! validatorOptions ||
75+ validatorOptions . forbidUnknownValues === undefined ||
76+ validatorOptions . forbidUnknownValues !== false ;
7577 this . whitelist = ( validatorOptions && validatorOptions . whitelist ) || false ;
7678 this . forbidNonWhitelisted = ( validatorOptions && validatorOptions . forbidNonWhitelisted ) || false ;
7779 }
@@ -95,7 +97,13 @@ export class ValidationExecutor {
9597 ) ;
9698 }
9799
98- const cacheKey = this . metadataStorage . buildCacheKey ( object . constructor , targetSchema , this . always , this . strictGroups , this . groups ) ;
100+ const cacheKey = this . metadataStorage . buildCacheKey (
101+ object . constructor ,
102+ targetSchema ,
103+ this . always ,
104+ this . strictGroups ,
105+ this . groups
106+ ) ;
99107 const targetMetadatas = this . metadataStorage . getTargetValidationMetadatas (
100108 object . constructor ,
101109 targetSchema ,
@@ -216,19 +224,25 @@ export class ValidationExecutor {
216224 for ( const metadata of metadatas ) {
217225 validationArguments . constraints = metadata . constraints ;
218226
219- if ( metadata . inlineValidate && ( ! metadata . each || ! ( Array . isArray ( value ) || value instanceof Set || value instanceof Map ) ) ) {
227+ if (
228+ metadata . inlineValidate &&
229+ ( ! metadata . each || ! ( Array . isArray ( value ) || value instanceof Set || value instanceof Map ) )
230+ ) {
220231 if ( this . stopAtFirstError && validationError && hasConstraints ( validationError . constraints ) ) continue ;
221232
222233 const validatedValue = metadata . inlineValidate ( value , validationArguments ) ;
223234 if ( validatedValue !== true && validatedValue !== false ) {
224- const promise = ( validatedValue as Promise < boolean > ) . then ( isValid => {
235+ const promise = ( validatedValue ) . then ( isValid => {
225236 if ( ! isValid ) {
226237 if ( ! validationError ) validationError = this . generateValidationError ( object , value , propertyName ) ;
227238 const [ type , message ] = this . createValidationErrorInline ( metadata , validationArguments ) ;
228239 validationError . constraints [ type ] = message ;
229240 if ( metadata . context ) {
230241 if ( ! validationError . contexts ) validationError . contexts = { } ;
231- validationError . contexts [ type ] = Object . assign ( validationError . contexts [ type ] || { } , metadata . context ) ;
242+ validationError . contexts [ type ] = Object . assign (
243+ validationError . contexts [ type ] || { } ,
244+ metadata . context
245+ ) ;
232246 }
233247 }
234248 } ) ;
@@ -255,7 +269,11 @@ export class ValidationExecutor {
255269
256270 if ( validationError ) {
257271 const hasAsyncPending = this . awaitingPromises . length > asyncCountBefore ;
258- if ( hasConstraints ( validationError . constraints ) || ( validationError . children && validationError . children . length > 0 ) || hasAsyncPending ) {
272+ if (
273+ hasConstraints ( validationError . constraints ) ||
274+ ( validationError . children && validationError . children . length > 0 ) ||
275+ hasAsyncPending
276+ ) {
259277 validationErrors . push ( validationError ) ;
260278 }
261279 } else if ( this . awaitingPromises . length > asyncCountBefore ) {
@@ -379,7 +397,10 @@ export class ValidationExecutor {
379397 validationArguments . constraints = metadata . constraints ;
380398
381399 // Fast path: inline validators (all built-in decorators) bypass constraint metadata dispatch
382- if ( metadata . inlineValidate && ( ! metadata . each || ! ( Array . isArray ( value ) || value instanceof Set || value instanceof Map ) ) ) {
400+ if (
401+ metadata . inlineValidate &&
402+ ( ! metadata . each || ! ( Array . isArray ( value ) || value instanceof Set || value instanceof Map ) )
403+ ) {
383404 if ( this . stopAtFirstError ) {
384405 const error = getError ( ) ;
385406 if ( hasConstraints ( error . constraints ) ) continue ;
@@ -388,7 +409,7 @@ export class ValidationExecutor {
388409 const validatedValue = metadata . inlineValidate ( value , validationArguments ) ;
389410 if ( validatedValue !== true && validatedValue !== false ) {
390411 // Async result (Promise)
391- const promise = ( validatedValue as Promise < boolean > ) . then ( isValid => {
412+ const promise = ( validatedValue ) . then ( isValid => {
392413 if ( ! isValid ) {
393414 const error = getError ( ) ;
394415 const [ type , message ] = this . createValidationErrorInline ( metadata , validationArguments ) ;
@@ -416,7 +437,8 @@ export class ValidationExecutor {
416437 continue ;
417438 }
418439
419- const constraintMetadatas = metadata . resolvedConstraints ??
440+ const constraintMetadatas =
441+ metadata . resolvedConstraints ??
420442 ( metadata . resolvedConstraints = this . metadataStorage . getTargetValidatorConstraints ( metadata . constraintCls ) ) ;
421443 for ( const customConstraintMetadata of constraintMetadatas ) {
422444 if ( customConstraintMetadata . async && this . ignoreAsyncValidations ) continue ;
@@ -508,10 +530,7 @@ export class ValidationExecutor {
508530 for ( const metadata of metadatas ) {
509531 if ( metadata . type !== ValidationTypes . NESTED_VALIDATION && metadata . type !== ValidationTypes . PROMISE_VALIDATION ) {
510532 continue ;
511- } else if (
512- this . stopAtFirstError &&
513- Object . keys ( error . constraints || { } ) . length > 0
514- ) {
533+ } else if ( this . stopAtFirstError && Object . keys ( error . constraints || { } ) . length > 0 ) {
515534 continue ;
516535 }
517536
@@ -549,9 +568,12 @@ export class ValidationExecutor {
549568 // Inline validators: use metadata.name directly
550569 type = metadata . name || metadata . type ;
551570 } else {
552- const customConstraints = metadata . resolvedConstraints ??
553- ( metadata . resolvedConstraints = this . metadataStorage . getTargetValidatorConstraints ( metadata . constraintCls ) ) ;
554- type = ( customConstraints [ 0 ] && customConstraints [ 0 ] . name ) ? customConstraints [ 0 ] . name : metadata . type ;
571+ const customConstraints =
572+ metadata . resolvedConstraints ??
573+ ( metadata . resolvedConstraints = this . metadataStorage . getTargetValidatorConstraints (
574+ metadata . constraintCls
575+ ) ) ;
576+ type = customConstraints [ 0 ] && customConstraints [ 0 ] . name ? customConstraints [ 0 ] . name : metadata . type ;
555577 }
556578 } else {
557579 type = metadata . type ;
0 commit comments