From a071a73e6dca70d8f422c03b65a6cbb6e36f75d0 Mon Sep 17 00:00:00 2001 From: lhonRafaat Date: Thu, 28 Nov 2024 17:46:02 +0300 Subject: [PATCH 1/3] fix(common): enforce string type in validationpipe strictly parse the value to string to avoid nested objects being passed if the type is explicitly set to string closes #14234 --- packages/common/pipes/validation.pipe.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/common/pipes/validation.pipe.ts b/packages/common/pipes/validation.pipe.ts index 6163ea0d4d5..11de63be218 100644 --- a/packages/common/pipes/validation.pipe.ts +++ b/packages/common/pipes/validation.pipe.ts @@ -206,6 +206,9 @@ export class ValidationPipe implements PipeTransform { if (metatype === Number) { return +value; } + if (metatype === String) { + return String(value); + } return value; } From 6563c18417dbcb4acb094db3c4d538a499daee4c Mon Sep 17 00:00:00 2001 From: lhonRafaat Date: Thu, 28 Nov 2024 21:22:22 +0300 Subject: [PATCH 2/3] fix(common): return undefined if string type value is undefined --- packages/common/pipes/validation.pipe.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/common/pipes/validation.pipe.ts b/packages/common/pipes/validation.pipe.ts index 11de63be218..ede40fb80eb 100644 --- a/packages/common/pipes/validation.pipe.ts +++ b/packages/common/pipes/validation.pipe.ts @@ -207,6 +207,9 @@ export class ValidationPipe implements PipeTransform { return +value; } if (metatype === String) { + if (isUndefined(value)) { + return undefined; + } return String(value); } return value; From 74c4376bbcc382cb8e64538c59edcd0c411ef3fd Mon Sep 17 00:00:00 2001 From: lhonRafaat Date: Fri, 29 Nov 2024 10:49:05 +0300 Subject: [PATCH 3/3] fix(common): enforce strin value if not undefined --- packages/common/pipes/validation.pipe.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/common/pipes/validation.pipe.ts b/packages/common/pipes/validation.pipe.ts index ede40fb80eb..a801fa64ce7 100644 --- a/packages/common/pipes/validation.pipe.ts +++ b/packages/common/pipes/validation.pipe.ts @@ -206,10 +206,7 @@ export class ValidationPipe implements PipeTransform { if (metatype === Number) { return +value; } - if (metatype === String) { - if (isUndefined(value)) { - return undefined; - } + if (metatype === String && !isUndefined(value)) { return String(value); } return value;