@lenne.tech/nest-server 11.4.4 → 11.4.5
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/dist/core/common/decorators/unified-field.decorator.d.ts +1 -0
- package/dist/core/common/decorators/unified-field.decorator.js +10 -1
- package/dist/core/common/decorators/unified-field.decorator.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js +489 -16
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/decorators/unified-field.decorator.ts +18 -1
- package/src/core/common/pipes/map-and-validate.pipe.ts +659 -19
|
@@ -6,6 +6,7 @@ import { ValidationOptions } from 'class-validator';
|
|
|
6
6
|
import { GraphQLScalarType } from 'graphql';
|
|
7
7
|
import { RoleEnum } from '../enums/role.enum';
|
|
8
8
|
import { RestrictedType } from './restricted.decorator';
|
|
9
|
+
export declare const nestedTypeRegistry: Map<string, any>;
|
|
9
10
|
export interface UnifiedFieldOptions {
|
|
10
11
|
description?: string;
|
|
11
12
|
enum?: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nestedTypeRegistry = void 0;
|
|
3
4
|
exports.UnifiedField = UnifiedField;
|
|
4
5
|
const graphql_1 = require("@nestjs/graphql");
|
|
5
6
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
@@ -8,6 +9,7 @@ const class_transformer_1 = require("class-transformer");
|
|
|
8
9
|
const class_validator_1 = require("class-validator");
|
|
9
10
|
const graphql_2 = require("graphql");
|
|
10
11
|
const restricted_decorator_1 = require("./restricted.decorator");
|
|
12
|
+
exports.nestedTypeRegistry = new Map();
|
|
11
13
|
function UnifiedField(opts = {}) {
|
|
12
14
|
return (target, propertyKey) => {
|
|
13
15
|
const metadataType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
@@ -47,6 +49,7 @@ function UnifiedField(opts = {}) {
|
|
|
47
49
|
swaggerOpts.required = false;
|
|
48
50
|
}
|
|
49
51
|
else {
|
|
52
|
+
(0, class_validator_1.IsDefined)()(target, propertyKey);
|
|
50
53
|
(0, class_validator_1.IsNotEmpty)()(target, propertyKey);
|
|
51
54
|
gqlOpts.nullable = false;
|
|
52
55
|
swaggerOpts.nullable = false;
|
|
@@ -103,9 +106,15 @@ function UnifiedField(opts = {}) {
|
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
108
|
if (!opts.isAny) {
|
|
106
|
-
if (
|
|
109
|
+
if (baseType === Date) {
|
|
110
|
+
(0, class_transformer_1.Type)(() => Date)(target, propertyKey);
|
|
111
|
+
}
|
|
112
|
+
else if (!isPrimitive(baseType) && !opts.enum && !isGraphQLScalar(baseType)) {
|
|
107
113
|
(0, class_transformer_1.Type)(() => baseType)(target, propertyKey);
|
|
108
114
|
(0, class_validator_1.ValidateNested)({ each: isArrayField })(target, propertyKey);
|
|
115
|
+
const className = target.constructor.name;
|
|
116
|
+
const registryKey = `${className}.${String(propertyKey)}`;
|
|
117
|
+
exports.nestedTypeRegistry.set(registryKey, baseType);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
120
|
if (opts.roles) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-field.decorator.js","sourceRoot":"","sources":["../../../../src/core/common/decorators/unified-field.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unified-field.decorator.js","sourceRoot":"","sources":["../../../../src/core/common/decorators/unified-field.decorator.ts"],"names":[],"mappings":";;;AA4EA,oCAsLC;AAlQD,6CAAsD;AACtD,+CAAqD;AACrD,6CAAkE;AAElE,yDAAyC;AACzC,qDAcyB;AACzB,qCAA4C;AAG5C,iEAAoE;AAIvD,QAAA,kBAAkB,GAAG,IAAI,GAAG,EAAe,CAAC;AAiDzD,SAAgB,YAAY,CAAC,OAA4B,EAAE;IACzD,OAAO,C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,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -8,10 +8,467 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MapAndValidatePipe = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
+
const class_transformer_1 = require("class-transformer");
|
|
11
12
|
const class_validator_1 = require("class-validator");
|
|
12
13
|
const util_1 = require("util");
|
|
14
|
+
const unified_field_decorator_1 = require("../decorators/unified-field.decorator");
|
|
13
15
|
const input_helper_1 = require("../helpers/input.helper");
|
|
14
16
|
const DEBUG_VALIDATION = process.env.DEBUG_VALIDATION === 'true';
|
|
17
|
+
function getPrototypeChain(target) {
|
|
18
|
+
const chain = [];
|
|
19
|
+
let current = target;
|
|
20
|
+
while (current && current !== Object.prototype) {
|
|
21
|
+
if (typeof current === 'function') {
|
|
22
|
+
chain.push(current);
|
|
23
|
+
current = Object.getPrototypeOf(current);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
current = Object.getPrototypeOf(current.constructor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return chain;
|
|
30
|
+
}
|
|
31
|
+
async function validateWithInheritance(object, originalPlainValue) {
|
|
32
|
+
const errors = [];
|
|
33
|
+
const metadataStorage = (0, class_validator_1.getMetadataStorage)();
|
|
34
|
+
const chain = getPrototypeChain(object.constructor);
|
|
35
|
+
if (DEBUG_VALIDATION) {
|
|
36
|
+
console.debug('Prototype chain for validation:', chain.map((c) => c.name));
|
|
37
|
+
console.debug('Original plain object had keys:', Object.keys(originalPlainValue || {}));
|
|
38
|
+
}
|
|
39
|
+
const validatedProperties = new Set();
|
|
40
|
+
for (const targetClass of chain) {
|
|
41
|
+
const allMetadata = metadataStorage.getTargetValidationMetadatas(targetClass, null, false, false);
|
|
42
|
+
const targetMetadata = allMetadata.filter((m) => m.target === targetClass);
|
|
43
|
+
if (targetMetadata && targetMetadata.length > 0) {
|
|
44
|
+
if (DEBUG_VALIDATION) {
|
|
45
|
+
console.debug(`Validating against ${targetClass.name} (${targetMetadata.length} constraints)`);
|
|
46
|
+
}
|
|
47
|
+
const tempInstance = Object.create(targetClass.prototype);
|
|
48
|
+
if (originalPlainValue) {
|
|
49
|
+
for (const key in originalPlainValue) {
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(originalPlainValue, key)) {
|
|
51
|
+
let value = object.hasOwnProperty(key) ? object[key] : originalPlainValue[key];
|
|
52
|
+
const designType = Reflect.getMetadata('design:type', targetClass.prototype, key);
|
|
53
|
+
if (designType === Date && typeof value === 'string') {
|
|
54
|
+
try {
|
|
55
|
+
const dateValue = new Date(value);
|
|
56
|
+
if (!isNaN(dateValue.getTime())) {
|
|
57
|
+
value = dateValue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
tempInstance[key] = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (DEBUG_VALIDATION) {
|
|
68
|
+
console.debug(` temp instance keys:`, Object.keys(tempInstance));
|
|
69
|
+
}
|
|
70
|
+
const propertiesByName = new Map();
|
|
71
|
+
targetMetadata.forEach((m) => {
|
|
72
|
+
if (!propertiesByName.has(m.propertyName)) {
|
|
73
|
+
propertiesByName.set(m.propertyName, []);
|
|
74
|
+
}
|
|
75
|
+
propertiesByName.get(m.propertyName).push(m);
|
|
76
|
+
});
|
|
77
|
+
const classErrors = [];
|
|
78
|
+
for (const [propertyName, metadataList] of Array.from(propertiesByName.entries())) {
|
|
79
|
+
if (validatedProperties.has(propertyName)) {
|
|
80
|
+
if (DEBUG_VALIDATION) {
|
|
81
|
+
console.debug(` Skipping ${propertyName} - already validated in child class`);
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const propertyValue = tempInstance[propertyName];
|
|
86
|
+
const isOptional = metadataList.some((m) => m.type === 'conditionalValidation' && m.name === 'isOptional');
|
|
87
|
+
const hasIsDefined = metadataList.some((m) => m.type === 'isDefined');
|
|
88
|
+
const validateIfMetadata = metadataList.find((m) => m.type === 'conditionalValidation' && !m.name);
|
|
89
|
+
if (validateIfMetadata && validateIfMetadata.constraints?.[0]) {
|
|
90
|
+
const conditionFn = validateIfMetadata.constraints[0];
|
|
91
|
+
let shouldValidate = false;
|
|
92
|
+
try {
|
|
93
|
+
shouldValidate = conditionFn(tempInstance, propertyValue);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (DEBUG_VALIDATION) {
|
|
97
|
+
console.debug(` Error evaluating ValidateIf condition for ${propertyName}:`, error);
|
|
98
|
+
}
|
|
99
|
+
shouldValidate = false;
|
|
100
|
+
}
|
|
101
|
+
if (!shouldValidate) {
|
|
102
|
+
if (DEBUG_VALIDATION) {
|
|
103
|
+
console.debug(` Property ${propertyName} skipped by ValidateIf condition`);
|
|
104
|
+
}
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!hasIsDefined && isOptional && (propertyValue === undefined || propertyValue === null)) {
|
|
109
|
+
if (DEBUG_VALIDATION) {
|
|
110
|
+
console.debug(` Property ${propertyName} is optional and undefined/null - skipping validation`);
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const propertyError = new class_validator_1.ValidationError();
|
|
115
|
+
propertyError.property = propertyName;
|
|
116
|
+
propertyError.value = propertyValue;
|
|
117
|
+
propertyError.target = tempInstance;
|
|
118
|
+
propertyError.constraints = {};
|
|
119
|
+
for (const metadata of metadataList) {
|
|
120
|
+
const constraintType = metadata.type;
|
|
121
|
+
let isValid = true;
|
|
122
|
+
let errorMessage = '';
|
|
123
|
+
const shouldValidateEach = Array.isArray(propertyValue) && (metadata.validationTypeOptions?.each || metadata.each);
|
|
124
|
+
switch (constraintType) {
|
|
125
|
+
case 'arrayMaxSize':
|
|
126
|
+
isValid = (0, class_validator_1.arrayMaxSize)(propertyValue, metadata.constraints?.[0]);
|
|
127
|
+
errorMessage = `${propertyName} must contain no more than ${metadata.constraints?.[0]} elements`;
|
|
128
|
+
break;
|
|
129
|
+
case 'arrayMinSize':
|
|
130
|
+
isValid = (0, class_validator_1.arrayMinSize)(propertyValue, metadata.constraints?.[0]);
|
|
131
|
+
errorMessage = `${propertyName} must contain at least ${metadata.constraints?.[0]} elements`;
|
|
132
|
+
break;
|
|
133
|
+
case 'customValidation':
|
|
134
|
+
if (metadata.constraintCls) {
|
|
135
|
+
try {
|
|
136
|
+
const constraintInstance = new metadata.constraintCls();
|
|
137
|
+
if (typeof constraintInstance.validate === 'function') {
|
|
138
|
+
const validationArgs = {
|
|
139
|
+
constraints: metadata.constraints || [],
|
|
140
|
+
object: tempInstance,
|
|
141
|
+
property: propertyName,
|
|
142
|
+
targetName: targetClass.name,
|
|
143
|
+
value: propertyValue,
|
|
144
|
+
};
|
|
145
|
+
const isArrayValue = Array.isArray(propertyValue);
|
|
146
|
+
const shouldValidateEach = metadata.each === true || metadata.validationOptions?.each === true;
|
|
147
|
+
if (isArrayValue && shouldValidateEach) {
|
|
148
|
+
const results = [];
|
|
149
|
+
for (const item of propertyValue) {
|
|
150
|
+
const itemArgs = {
|
|
151
|
+
...validationArgs,
|
|
152
|
+
value: item,
|
|
153
|
+
};
|
|
154
|
+
const itemResult = constraintInstance.validate(item, itemArgs);
|
|
155
|
+
const itemValid = itemResult instanceof Promise ? await itemResult : itemResult;
|
|
156
|
+
results.push(itemValid);
|
|
157
|
+
}
|
|
158
|
+
isValid = results.every((r) => r === true);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const validationResult = constraintInstance.validate(propertyValue, validationArgs);
|
|
162
|
+
isValid = validationResult instanceof Promise ? await validationResult : validationResult;
|
|
163
|
+
}
|
|
164
|
+
if (!isValid) {
|
|
165
|
+
const constraintName = metadata.name || 'customValidation';
|
|
166
|
+
if (typeof constraintInstance.defaultMessage === 'function') {
|
|
167
|
+
errorMessage = constraintInstance.defaultMessage(validationArgs);
|
|
168
|
+
errorMessage = errorMessage.replace(/\$property/g, propertyName);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
errorMessage = `${propertyName} failed custom validation`;
|
|
172
|
+
}
|
|
173
|
+
propertyError.constraints[constraintName] = errorMessage;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
if (DEBUG_VALIDATION) {
|
|
179
|
+
console.debug(` Skipping customValidation for ${propertyName} - no validate method`);
|
|
180
|
+
}
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (DEBUG_VALIDATION) {
|
|
186
|
+
console.debug(` Error executing customValidation for ${propertyName}:`, error);
|
|
187
|
+
}
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
if (DEBUG_VALIDATION) {
|
|
193
|
+
console.debug(` Skipping customValidation for ${propertyName} - no constraint class`);
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
case 'nestedValidation':
|
|
199
|
+
if (DEBUG_VALIDATION) {
|
|
200
|
+
console.debug(` Nested validation for ${propertyName}`);
|
|
201
|
+
}
|
|
202
|
+
if (propertyValue !== undefined && propertyValue !== null) {
|
|
203
|
+
const nestedErrors = [];
|
|
204
|
+
const registryKey = `${targetClass.name}.${propertyName}`;
|
|
205
|
+
const nestedType = unified_field_decorator_1.nestedTypeRegistry.get(registryKey);
|
|
206
|
+
if (DEBUG_VALIDATION) {
|
|
207
|
+
console.debug(`[NESTED] Looking up ${registryKey}, found:`, nestedType?.name);
|
|
208
|
+
}
|
|
209
|
+
if (Array.isArray(propertyValue)) {
|
|
210
|
+
for (let i = 0; i < propertyValue.length; i++) {
|
|
211
|
+
const item = propertyValue[i];
|
|
212
|
+
if (item && typeof item === 'object') {
|
|
213
|
+
if (!nestedType) {
|
|
214
|
+
if (DEBUG_VALIDATION) {
|
|
215
|
+
console.debug(`[NESTED] Skipping validation for array item ${i} - no type info`);
|
|
216
|
+
}
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
let transformedItem = item;
|
|
220
|
+
if (!item.constructor || item.constructor === Object) {
|
|
221
|
+
transformedItem = (0, class_transformer_1.plainToInstance)(nestedType, item, {
|
|
222
|
+
enableImplicitConversion: false,
|
|
223
|
+
excludeExtraneousValues: false,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (DEBUG_VALIDATION) {
|
|
227
|
+
console.debug(`[NESTED] Validating array item ${i}:`);
|
|
228
|
+
console.debug(`[NESTED] Original type: ${item.constructor?.name}`);
|
|
229
|
+
console.debug(`[NESTED] Transformed type: ${transformedItem.constructor?.name}`);
|
|
230
|
+
console.debug(`[NESTED] Target type: ${nestedType?.name}`);
|
|
231
|
+
}
|
|
232
|
+
if (!transformedItem || typeof transformedItem !== 'object') {
|
|
233
|
+
if (DEBUG_VALIDATION) {
|
|
234
|
+
console.debug(`[NESTED] Skipping validation - invalid transformed item`);
|
|
235
|
+
}
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const itemErrors = await validateWithInheritance(transformedItem, item);
|
|
239
|
+
if (itemErrors.length > 0 && DEBUG_VALIDATION) {
|
|
240
|
+
console.debug(`[NESTED] Errors (${itemErrors.length}):`);
|
|
241
|
+
itemErrors.forEach((err, idx) => {
|
|
242
|
+
console.debug(`[NESTED] Error ${idx}: property="${err.property}", constraints=${JSON.stringify(err.constraints)}`);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (itemErrors.length > 0) {
|
|
246
|
+
itemErrors.forEach((err) => {
|
|
247
|
+
err.property = `${i}.${err.property}`;
|
|
248
|
+
});
|
|
249
|
+
nestedErrors.push(...itemErrors);
|
|
250
|
+
if (DEBUG_VALIDATION) {
|
|
251
|
+
console.debug(` Found ${itemErrors.length} errors in item ${i}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else if (typeof propertyValue === 'object') {
|
|
258
|
+
if (!nestedType) {
|
|
259
|
+
if (DEBUG_VALIDATION) {
|
|
260
|
+
console.debug(`[NESTED] Skipping validation for single object - no type info`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
let transformedItem = propertyValue;
|
|
265
|
+
if (!propertyValue.constructor || propertyValue.constructor === Object) {
|
|
266
|
+
transformedItem = (0, class_transformer_1.plainToInstance)(nestedType, propertyValue, {
|
|
267
|
+
enableImplicitConversion: false,
|
|
268
|
+
excludeExtraneousValues: false,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (DEBUG_VALIDATION) {
|
|
272
|
+
console.debug(`[NESTED] Validating single object:`);
|
|
273
|
+
console.debug(`[NESTED] Original type: ${propertyValue.constructor?.name}`);
|
|
274
|
+
console.debug(`[NESTED] Transformed type: ${transformedItem.constructor?.name}`);
|
|
275
|
+
console.debug(`[NESTED] Target type: ${nestedType?.name}`);
|
|
276
|
+
}
|
|
277
|
+
if (!transformedItem || typeof transformedItem !== 'object') {
|
|
278
|
+
if (DEBUG_VALIDATION) {
|
|
279
|
+
console.debug(`[NESTED] Skipping validation - invalid transformed item`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
const itemErrors = await validateWithInheritance(transformedItem, propertyValue);
|
|
284
|
+
if (itemErrors.length > 0 && DEBUG_VALIDATION) {
|
|
285
|
+
console.debug(`[NESTED] Errors (${itemErrors.length}):`, itemErrors);
|
|
286
|
+
}
|
|
287
|
+
if (itemErrors.length > 0) {
|
|
288
|
+
nestedErrors.push(...itemErrors);
|
|
289
|
+
if (DEBUG_VALIDATION) {
|
|
290
|
+
console.debug(` Found ${itemErrors.length} errors in nested object`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (nestedErrors.length > 0) {
|
|
297
|
+
propertyError.children = nestedErrors;
|
|
298
|
+
if (DEBUG_VALIDATION) {
|
|
299
|
+
console.debug(` Total nested errors for ${propertyName}: ${nestedErrors.length}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
continue;
|
|
304
|
+
case 'isArray':
|
|
305
|
+
isValid = (0, class_validator_1.isArray)(propertyValue);
|
|
306
|
+
errorMessage = `${propertyName} must be an array`;
|
|
307
|
+
break;
|
|
308
|
+
case 'isBoolean':
|
|
309
|
+
if (shouldValidateEach) {
|
|
310
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isBoolean)(item));
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
isValid = (0, class_validator_1.isBoolean)(propertyValue);
|
|
314
|
+
}
|
|
315
|
+
errorMessage = `${propertyName} must be a boolean value`;
|
|
316
|
+
break;
|
|
317
|
+
case 'isDate':
|
|
318
|
+
if (shouldValidateEach) {
|
|
319
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isDate)(item));
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
isValid = (0, class_validator_1.isDate)(propertyValue);
|
|
323
|
+
}
|
|
324
|
+
errorMessage = `${propertyName} must be a Date instance`;
|
|
325
|
+
break;
|
|
326
|
+
case 'isDateString':
|
|
327
|
+
if (shouldValidateEach) {
|
|
328
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isDateString)(item, metadata.constraints?.[0]));
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
isValid = (0, class_validator_1.isDateString)(propertyValue, metadata.constraints?.[0]);
|
|
332
|
+
}
|
|
333
|
+
errorMessage = `${propertyName} must be a valid ISO 8601 date string`;
|
|
334
|
+
break;
|
|
335
|
+
case 'isDefined':
|
|
336
|
+
isValid = (0, class_validator_1.isDefined)(propertyValue);
|
|
337
|
+
errorMessage = `${propertyName} should not be null or undefined`;
|
|
338
|
+
break;
|
|
339
|
+
case 'isEmail':
|
|
340
|
+
if (shouldValidateEach) {
|
|
341
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isEmail)(item, metadata.constraints?.[0]));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
isValid = (0, class_validator_1.isEmail)(propertyValue, metadata.constraints?.[0]);
|
|
345
|
+
}
|
|
346
|
+
errorMessage = `${propertyName} must be an email`;
|
|
347
|
+
break;
|
|
348
|
+
case 'isEnum':
|
|
349
|
+
if (shouldValidateEach) {
|
|
350
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isEnum)(item, metadata.constraints?.[0]));
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
isValid = (0, class_validator_1.isEnum)(propertyValue, metadata.constraints?.[0]);
|
|
354
|
+
}
|
|
355
|
+
errorMessage = `${propertyName} must be a valid enum value`;
|
|
356
|
+
break;
|
|
357
|
+
case 'isInt':
|
|
358
|
+
if (shouldValidateEach) {
|
|
359
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isInt)(item));
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
isValid = (0, class_validator_1.isInt)(propertyValue);
|
|
363
|
+
}
|
|
364
|
+
errorMessage = `${propertyName} must be an integer number`;
|
|
365
|
+
break;
|
|
366
|
+
case 'isNotEmpty':
|
|
367
|
+
if (shouldValidateEach) {
|
|
368
|
+
isValid = propertyValue.every((item) => !(0, class_validator_1.isEmpty)(item));
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
isValid = !(0, class_validator_1.isEmpty)(propertyValue);
|
|
372
|
+
}
|
|
373
|
+
errorMessage = `${propertyName} should not be empty`;
|
|
374
|
+
break;
|
|
375
|
+
case 'isNumber':
|
|
376
|
+
if (shouldValidateEach) {
|
|
377
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isNumber)(item, metadata.constraints?.[0]));
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
isValid = (0, class_validator_1.isNumber)(propertyValue, metadata.constraints?.[0]);
|
|
381
|
+
}
|
|
382
|
+
errorMessage = `${propertyName} must be a number conforming to the specified constraints`;
|
|
383
|
+
break;
|
|
384
|
+
case 'isString':
|
|
385
|
+
if (shouldValidateEach) {
|
|
386
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isString)(item));
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
isValid = (0, class_validator_1.isString)(propertyValue);
|
|
390
|
+
}
|
|
391
|
+
errorMessage = `${propertyName} must be a string`;
|
|
392
|
+
break;
|
|
393
|
+
case 'isUrl':
|
|
394
|
+
if (shouldValidateEach) {
|
|
395
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.isURL)(item, metadata.constraints?.[0]));
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
isValid = (0, class_validator_1.isURL)(propertyValue, metadata.constraints?.[0]);
|
|
399
|
+
}
|
|
400
|
+
errorMessage = `${propertyName} must be an URL address`;
|
|
401
|
+
break;
|
|
402
|
+
case 'max':
|
|
403
|
+
if (shouldValidateEach) {
|
|
404
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.max)(item, metadata.constraints?.[0]));
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
isValid = (0, class_validator_1.max)(propertyValue, metadata.constraints?.[0]);
|
|
408
|
+
}
|
|
409
|
+
errorMessage = `${propertyName} must not be greater than ${metadata.constraints?.[0]}`;
|
|
410
|
+
break;
|
|
411
|
+
case 'maxLength':
|
|
412
|
+
if (shouldValidateEach) {
|
|
413
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.maxLength)(item, metadata.constraints?.[0]));
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
isValid = (0, class_validator_1.maxLength)(propertyValue, metadata.constraints?.[0]);
|
|
417
|
+
}
|
|
418
|
+
errorMessage = `${propertyName} must be shorter than or equal to ${metadata.constraints?.[0]} characters`;
|
|
419
|
+
break;
|
|
420
|
+
case 'min':
|
|
421
|
+
if (shouldValidateEach) {
|
|
422
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.min)(item, metadata.constraints?.[0]));
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
isValid = (0, class_validator_1.min)(propertyValue, metadata.constraints?.[0]);
|
|
426
|
+
}
|
|
427
|
+
errorMessage = `${propertyName} must not be less than ${metadata.constraints?.[0]}`;
|
|
428
|
+
break;
|
|
429
|
+
case 'minLength':
|
|
430
|
+
if (shouldValidateEach) {
|
|
431
|
+
isValid = propertyValue.every((item) => (0, class_validator_1.minLength)(item, metadata.constraints?.[0]));
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
isValid = (0, class_validator_1.minLength)(propertyValue, metadata.constraints?.[0]);
|
|
435
|
+
}
|
|
436
|
+
errorMessage = `${propertyName} must be longer than or equal to ${metadata.constraints?.[0]} characters`;
|
|
437
|
+
break;
|
|
438
|
+
default:
|
|
439
|
+
if (DEBUG_VALIDATION) {
|
|
440
|
+
console.debug(` Skipping unknown constraint type: ${constraintType} for ${propertyName}`);
|
|
441
|
+
}
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (!isValid) {
|
|
445
|
+
propertyError.constraints[constraintType] = errorMessage;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (Object.keys(propertyError.constraints).length > 0 ||
|
|
449
|
+
(propertyError.children && propertyError.children.length > 0)) {
|
|
450
|
+
classErrors.push(propertyError);
|
|
451
|
+
}
|
|
452
|
+
validatedProperties.add(propertyName);
|
|
453
|
+
}
|
|
454
|
+
if (DEBUG_VALIDATION) {
|
|
455
|
+
console.debug(` Manual validation found ${classErrors.length} errors`);
|
|
456
|
+
if (classErrors.length > 0) {
|
|
457
|
+
classErrors.forEach((err, idx) => {
|
|
458
|
+
console.debug(` Error ${idx + 1}: property="${err.property}", constraints=${JSON.stringify(err.constraints)}`);
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (classErrors.length > 0) {
|
|
463
|
+
if (DEBUG_VALIDATION) {
|
|
464
|
+
console.debug(`Found ${classErrors.length} errors in ${targetClass.name}`);
|
|
465
|
+
}
|
|
466
|
+
errors.push(...classErrors);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return errors;
|
|
471
|
+
}
|
|
15
472
|
let MapAndValidatePipe = class MapAndValidatePipe {
|
|
16
473
|
async transform(value, metadata) {
|
|
17
474
|
const { metatype } = metadata;
|
|
@@ -32,28 +489,30 @@ let MapAndValidatePipe = class MapAndValidatePipe {
|
|
|
32
489
|
}
|
|
33
490
|
return value;
|
|
34
491
|
}
|
|
492
|
+
let originalPlainValue = null;
|
|
493
|
+
let originalPlainKeys = [];
|
|
494
|
+
const hasCustomMap = !!metatype?.map;
|
|
35
495
|
if (!(value instanceof metatype)) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value = metatype?.map(value);
|
|
496
|
+
originalPlainValue = value;
|
|
497
|
+
originalPlainKeys = Object.keys(value);
|
|
498
|
+
if (DEBUG_VALIDATION) {
|
|
499
|
+
console.debug('Using plainToInstance to transform to:', metatype.name);
|
|
41
500
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
501
|
+
value = (0, class_transformer_1.plainToInstance)(metatype, value, {
|
|
502
|
+
enableImplicitConversion: false,
|
|
503
|
+
excludeExtraneousValues: false,
|
|
504
|
+
exposeDefaultValues: false,
|
|
505
|
+
exposeUnsetFields: false,
|
|
506
|
+
});
|
|
507
|
+
if (DEBUG_VALIDATION) {
|
|
508
|
+
console.debug('Transformed value:', (0, util_1.inspect)(value, { colors: true, depth: 3 }));
|
|
509
|
+
console.debug('Transformed value instance of:', value?.constructor?.name);
|
|
51
510
|
}
|
|
52
511
|
}
|
|
53
512
|
if (DEBUG_VALIDATION) {
|
|
54
|
-
console.debug('Starting validation
|
|
513
|
+
console.debug('Starting validation with inheritance');
|
|
55
514
|
}
|
|
56
|
-
const errors = await (
|
|
515
|
+
const errors = await validateWithInheritance(value, originalPlainValue);
|
|
57
516
|
if (errors.length > 0) {
|
|
58
517
|
if (DEBUG_VALIDATION) {
|
|
59
518
|
console.debug('Validation errors found:', errors.length);
|
|
@@ -118,6 +577,20 @@ let MapAndValidatePipe = class MapAndValidatePipe {
|
|
|
118
577
|
}
|
|
119
578
|
if (DEBUG_VALIDATION) {
|
|
120
579
|
console.debug('Validation successful - no errors');
|
|
580
|
+
}
|
|
581
|
+
if (hasCustomMap && originalPlainKeys.length > 0) {
|
|
582
|
+
for (const key in value) {
|
|
583
|
+
if (Object.prototype.hasOwnProperty.call(value, key) &&
|
|
584
|
+
!originalPlainKeys.includes(key) &&
|
|
585
|
+
value[key] === undefined) {
|
|
586
|
+
delete value[key];
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (DEBUG_VALIDATION) {
|
|
590
|
+
console.debug('After CoreInput cleanup:', (0, util_1.inspect)(value, { colors: true, depth: 3 }));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (DEBUG_VALIDATION) {
|
|
121
594
|
console.debug('=== End Debug ===\n');
|
|
122
595
|
}
|
|
123
596
|
return value;
|