@nestjs/common 11.0.8 → 11.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pipes/validation.pipe.js +7 -1
package/package.json
CHANGED
package/pipes/validation.pipe.js
CHANGED
|
@@ -73,6 +73,12 @@ let ValidationPipe = class ValidationPipe {
|
|
|
73
73
|
if (errors.length > 0) {
|
|
74
74
|
throw await this.exceptionFactory(errors);
|
|
75
75
|
}
|
|
76
|
+
if (originalValue === undefined && originalEntity === '') {
|
|
77
|
+
// Since SWC requires empty string for validation (to avoid an error),
|
|
78
|
+
// a fallback is needed to revert to the original value (when undefined).
|
|
79
|
+
// @see https://github.com/nestjs/nest/issues/14430
|
|
80
|
+
return originalValue;
|
|
81
|
+
}
|
|
76
82
|
if (isPrimitive) {
|
|
77
83
|
// if the value is a primitive value and the validation process has been successfully completed
|
|
78
84
|
// we have to revert the original value passed through the pipe
|
|
@@ -150,7 +156,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
150
156
|
(metatype && 'prototype' in metatype && metatype.prototype?.constructor)) {
|
|
151
157
|
return {};
|
|
152
158
|
}
|
|
153
|
-
//
|
|
159
|
+
// SWC requires empty string to be returned instead of an empty object
|
|
154
160
|
// when the value is nil and the metatype is not a class instance, but a plain object (enum, for example).
|
|
155
161
|
// Otherwise, the error will be thrown.
|
|
156
162
|
// @see https://github.com/nestjs/nest/issues/12680
|