@nestjs/common 10.4.7 → 10.4.9
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/Readme.md
CHANGED
|
@@ -94,7 +94,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
94
94
|
<td><a href="https://www.mercedes-benz.com/" target="_blank"><img src="https://nestjs.com/img/logos/mercedes-logo.png" width="100" valign="middle" /></a></td>
|
|
95
95
|
<td><a href="https://www.dinii.jp/" target="_blank"><img src="https://nestjs.com/img/logos/dinii-logo.png" width="65" valign="middle" /></a></td>
|
|
96
96
|
<td><a href="https://bloodycase.com/?promocode=NEST" target="_blank"><img src="https://nestjs.com/img/logos/bloodycase-logo.png" width="65" valign="middle" /></a></td>
|
|
97
|
-
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/logos/handsontable-logo.svg" width="150" valign="middle" /></a></td>
|
|
97
|
+
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/logos/handsontable-dark-logo.svg#2" width="150" valign="middle" /></a></td>
|
|
98
98
|
<td align="center" valign="middle"><a href="https://www.itflashcards.com/" target="_blank"><img src="https://nestjs.com/img/logos/it_flashcards-logo.png" width="170" valign="middle" /></a></td>
|
|
99
99
|
<td align="center" valign="middle"><a href="https://arcjet.com/?ref=nestjs" target="_blank"><img src="https://nestjs.com/img/logos/arcjet-logo.svg" width="170" valign="middle" /></a></td>
|
|
100
100
|
</tr>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInjectionProviders = getInjectionProviders;
|
|
4
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param x
|
|
8
|
-
* @returns x is OptionalFactoryDependency
|
|
6
|
+
* @param value
|
|
7
|
+
* @returns `true` if value is `OptionalFactoryDependency`
|
|
9
8
|
*/
|
|
10
|
-
function isOptionalFactoryDependency(
|
|
11
|
-
return
|
|
9
|
+
function isOptionalFactoryDependency(value) {
|
|
10
|
+
return (!(0, shared_utils_1.isUndefined)(value.token) &&
|
|
11
|
+
!(0, shared_utils_1.isUndefined)(value.optional) &&
|
|
12
|
+
!value.prototype);
|
|
12
13
|
}
|
|
13
14
|
const mapInjectToTokens = (t) => isOptionalFactoryDependency(t) ? t.token : t;
|
|
14
15
|
/**
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ export declare class ValidationPipe implements PipeTransform<any> {
|
|
|
41
41
|
createExceptionFactory(): (validationErrors?: ValidationError[]) => unknown;
|
|
42
42
|
protected toValidate(metadata: ArgumentMetadata): boolean;
|
|
43
43
|
protected transformPrimitive(value: any, metadata: ArgumentMetadata): any;
|
|
44
|
-
protected toEmptyIfNil<T = any, R = any>(value: T): R | {};
|
|
44
|
+
protected toEmptyIfNil<T = any, R = any>(value: T, metatype: Type<unknown> | object): R | {};
|
|
45
45
|
protected stripProtoKeys(value: any): void;
|
|
46
46
|
protected isPrimitive(value: unknown): boolean;
|
|
47
47
|
protected validate(object: object, validatorOptions?: ValidatorOptions): Promise<ValidationError[]> | ValidationError[];
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -53,7 +53,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
53
53
|
: value;
|
|
54
54
|
}
|
|
55
55
|
const originalValue = value;
|
|
56
|
-
value = this.toEmptyIfNil(value);
|
|
56
|
+
value = this.toEmptyIfNil(value, metatype);
|
|
57
57
|
const isNil = value !== originalValue;
|
|
58
58
|
const isPrimitive = this.isPrimitive(value);
|
|
59
59
|
this.stripProtoKeys(value);
|
|
@@ -133,8 +133,19 @@ let ValidationPipe = class ValidationPipe {
|
|
|
133
133
|
}
|
|
134
134
|
return value;
|
|
135
135
|
}
|
|
136
|
-
toEmptyIfNil(value) {
|
|
137
|
-
|
|
136
|
+
toEmptyIfNil(value, metatype) {
|
|
137
|
+
if (!(0, shared_utils_1.isNil)(value)) {
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
if (typeof metatype === 'function' ||
|
|
141
|
+
(metatype && 'prototype' in metatype && metatype.prototype?.constructor)) {
|
|
142
|
+
return {};
|
|
143
|
+
}
|
|
144
|
+
// Builder like SWC require empty string to be returned instead of an empty object
|
|
145
|
+
// when the value is nil and the metatype is not a class instance, but a plain object (enum, for example).
|
|
146
|
+
// Otherwise, the error will be thrown.
|
|
147
|
+
// @see https://github.com/nestjs/nest/issues/12680
|
|
148
|
+
return '';
|
|
138
149
|
}
|
|
139
150
|
stripProtoKeys(value) {
|
|
140
151
|
if (value == null ||
|