From 34e4dc166652356772b414c7d263cfca9bef32cf Mon Sep 17 00:00:00 2001 From: coxxny Date: Tue, 28 Jul 2026 08:59:02 +0900 Subject: [PATCH 1/2] fix(common): exclude pipe options from validator options --- packages/common/pipes/validation.pipe.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/common/pipes/validation.pipe.ts b/packages/common/pipes/validation.pipe.ts index 3cd36769888..654e6c84791 100644 --- a/packages/common/pipes/validation.pipe.ts +++ b/packages/common/pipes/validation.pipe.ts @@ -68,6 +68,9 @@ export class ValidationPipe implements PipeTransform { errorHttpStatusCode, expectedType, transformOptions, + exceptionFactory, + validatorPackage, + transformerPackage, validateCustomDecorators, ...validatorOptions } = options; @@ -81,11 +84,10 @@ export class ValidationPipe implements PipeTransform { this.validateCustomDecorators = validateCustomDecorators || false; this.errorHttpStatusCode = errorHttpStatusCode || HttpStatus.BAD_REQUEST; this.expectedType = expectedType; - this.exceptionFactory = - options.exceptionFactory || this.createExceptionFactory(); + this.exceptionFactory = exceptionFactory || this.createExceptionFactory(); - classValidator = this.loadValidator(options.validatorPackage); - classTransformer = this.loadTransformer(options.transformerPackage); + classValidator = this.loadValidator(validatorPackage); + classTransformer = this.loadTransformer(transformerPackage); } protected loadValidator( From 1e11696f41a1b4a4a09dc6cfc3d188553c0047e8 Mon Sep 17 00:00:00 2001 From: coxxny Date: Thu, 30 Jul 2026 10:17:37 +0900 Subject: [PATCH 2/2] fix(common): added test for #17398 --- .../common/test/pipes/validation.pipe.spec.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/common/test/pipes/validation.pipe.spec.ts b/packages/common/test/pipes/validation.pipe.spec.ts index 3d54bf282dc..86de2593ea2 100644 --- a/packages/common/test/pipes/validation.pipe.spec.ts +++ b/packages/common/test/pipes/validation.pipe.spec.ts @@ -738,4 +738,32 @@ describe('ValidationPipe', () => { }); }); }); + describe('Issue #17398: when only ValidationPipe-specific options are provided', () => { + it('should return the original value when exceptionFactory is provided', async () => { + target = new ValidationPipe({ + exceptionFactory: () => new Error('custom'), + }); + const testObj = { prop1: 'value1', prop2: 'value2' }; + const result = await target.transform(testObj, metadata); + expect(result).to.equal(testObj); + }); + + it('should return the original value when validatorPackage is provided', async () => { + target = new ValidationPipe({ + validatorPackage: require('class-validator'), + }); + const testObj = { prop1: 'value1', prop2: 'value2' }; + const result = await target.transform(testObj, metadata); + expect(result).to.equal(testObj); + }); + + it('should return the original value when transformerPackage is provided', async () => { + target = new ValidationPipe({ + transformerPackage: require('class-transformer'), + }); + const testObj = { prop1: 'value1', prop2: 'value2' }; + const result = await target.transform(testObj, metadata); + expect(result).to.equal(testObj); + }); + }); });