@rotyro-tools/nestjs-typeorm-validator 1.0.0
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/LICENSE.md +21 -0
- package/README.md +239 -0
- package/dist/index.d.mts +157 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.js +429 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +407 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +122 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var __decoratorStart = (base) => {
|
|
27
|
+
var _a3;
|
|
28
|
+
return [, , , __create((_a3 = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a3 : null)];
|
|
29
|
+
};
|
|
30
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
31
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
32
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
33
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
34
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
35
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
39
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
40
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
41
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
42
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
43
|
+
return __privateGet(this, extra);
|
|
44
|
+
}, set [name](x) {
|
|
45
|
+
return __privateSet(this, extra, x);
|
|
46
|
+
} }, name));
|
|
47
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
48
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
49
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
50
|
+
if (k) {
|
|
51
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
52
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
53
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
54
|
+
}
|
|
55
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
56
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
57
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
58
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
59
|
+
}
|
|
60
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
61
|
+
};
|
|
62
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
63
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
64
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
65
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
66
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
67
|
+
|
|
68
|
+
// src/index.ts
|
|
69
|
+
var index_exports = {};
|
|
70
|
+
__export(index_exports, {
|
|
71
|
+
ExistsIn: () => ExistsIn,
|
|
72
|
+
UniqueIn: () => UniqueIn,
|
|
73
|
+
registerDataSourceForValidation: () => registerDataSourceForValidation
|
|
74
|
+
});
|
|
75
|
+
module.exports = __toCommonJS(index_exports);
|
|
76
|
+
|
|
77
|
+
// src/errors/validator.error.ts
|
|
78
|
+
var ValidatorError = class extends Error {
|
|
79
|
+
constructor(message, cause) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.cause = cause;
|
|
82
|
+
this.name = this.constructor.name;
|
|
83
|
+
if (Error.captureStackTrace) {
|
|
84
|
+
Error.captureStackTrace(this, this.constructor);
|
|
85
|
+
}
|
|
86
|
+
if (cause == null ? void 0 : cause.stack) {
|
|
87
|
+
this.stack = `${this.stack}
|
|
88
|
+
Caused by: ${cause.stack}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/errors/validation-configuration.error.ts
|
|
94
|
+
var ValidationConfigurationError = class extends ValidatorError {
|
|
95
|
+
constructor(message, context) {
|
|
96
|
+
super(message);
|
|
97
|
+
this.context = context;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/errors/validation-query.error.ts
|
|
102
|
+
var ValidationQueryError = class extends ValidatorError {
|
|
103
|
+
constructor(message, cause, context) {
|
|
104
|
+
super(message, cause);
|
|
105
|
+
this.context = context;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/errors/data-source-initialization.error.ts
|
|
110
|
+
var DataSourceInitializationError = class extends ValidatorError {
|
|
111
|
+
constructor(dataSourceName, cause) {
|
|
112
|
+
super(
|
|
113
|
+
`DataSource "${dataSourceName}" is not initialized. Please ensure it's initialized before use.`,
|
|
114
|
+
cause
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/errors/data-source-not-registered.error.ts
|
|
120
|
+
var DataSourceNotRegisteredError = class extends ValidatorError {
|
|
121
|
+
constructor(dataSourceName = "default") {
|
|
122
|
+
super(
|
|
123
|
+
`DataSource "${dataSourceName}" is not registered. Please call registerDataSourceForValidation() first.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/errors/data-source-invalid.error.ts
|
|
129
|
+
var DataSourceInvalidError = class extends ValidatorError {
|
|
130
|
+
constructor(cause) {
|
|
131
|
+
super(`Invalid DataSource instance provided`, cause);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/utils/data-source.util.ts
|
|
136
|
+
var dataSources = /* @__PURE__ */ new Map();
|
|
137
|
+
var DEFAULT_DATA_SOURCE_NAME = "default";
|
|
138
|
+
function registerDataSourceForValidation(dataSourceInstance, dataSourceName) {
|
|
139
|
+
if (!dataSourceInstance || typeof dataSourceInstance.getRepository !== "function") {
|
|
140
|
+
throw new DataSourceInvalidError();
|
|
141
|
+
}
|
|
142
|
+
const normalizedName = normalizeDataSourceName(dataSourceName);
|
|
143
|
+
dataSources.set(normalizedName, dataSourceInstance);
|
|
144
|
+
}
|
|
145
|
+
async function getDataSourceForValidation(dataSourceName) {
|
|
146
|
+
const normalizedName = normalizeDataSourceName(dataSourceName);
|
|
147
|
+
const dataSource = dataSources.get(normalizedName);
|
|
148
|
+
if (!dataSource) {
|
|
149
|
+
throw new DataSourceNotRegisteredError(normalizedName);
|
|
150
|
+
}
|
|
151
|
+
if (!dataSource.isInitialized) {
|
|
152
|
+
await dataSource.initialize();
|
|
153
|
+
}
|
|
154
|
+
if (!dataSource.isInitialized) {
|
|
155
|
+
throw new DataSourceInitializationError(normalizedName);
|
|
156
|
+
}
|
|
157
|
+
return dataSource;
|
|
158
|
+
}
|
|
159
|
+
function normalizeDataSourceName(dataSourceName) {
|
|
160
|
+
if (dataSourceName === null || dataSourceName === void 0) {
|
|
161
|
+
return DEFAULT_DATA_SOURCE_NAME;
|
|
162
|
+
}
|
|
163
|
+
if (typeof dataSourceName !== "string") {
|
|
164
|
+
throw new DataSourceInvalidError();
|
|
165
|
+
}
|
|
166
|
+
const trimmed = dataSourceName.trim();
|
|
167
|
+
if (trimmed === "") {
|
|
168
|
+
return DEFAULT_DATA_SOURCE_NAME;
|
|
169
|
+
}
|
|
170
|
+
return trimmed;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/decorators/exists-in.decorator.ts
|
|
174
|
+
var import_class_validator3 = require("class-validator");
|
|
175
|
+
|
|
176
|
+
// src/validators/base.validator.ts
|
|
177
|
+
var BaseValidator = class {
|
|
178
|
+
/**
|
|
179
|
+
* Validates the configuration constraints.
|
|
180
|
+
*
|
|
181
|
+
* @param validatorArguments - Validation arguments
|
|
182
|
+
* @throws {ValidationConfigurationError} if constraints are invalid
|
|
183
|
+
*
|
|
184
|
+
* @protected
|
|
185
|
+
*/
|
|
186
|
+
validateConstraints(validatorArguments, validatorName) {
|
|
187
|
+
const [entityOrTableName, columnName] = validatorArguments.constraints;
|
|
188
|
+
if (!entityOrTableName || !columnName) {
|
|
189
|
+
throw new ValidationConfigurationError(
|
|
190
|
+
`${validatorName}: entity/table name and column name are required`,
|
|
191
|
+
{
|
|
192
|
+
property: validatorArguments.property,
|
|
193
|
+
constraints: validatorArguments.constraints
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Executes a database query to check for value existence.
|
|
200
|
+
*
|
|
201
|
+
* Returns a tuple: [anyExists, allExists]
|
|
202
|
+
* - anyExists: true if at least one of the provided values exists
|
|
203
|
+
* - allExists: true if all of the provided values exist
|
|
204
|
+
*
|
|
205
|
+
* For single values both flags are identical.
|
|
206
|
+
*
|
|
207
|
+
* @param value - The value to query
|
|
208
|
+
* @param validatorArguments - Validator arguments
|
|
209
|
+
* @returns Promise resolving to [anyExists, allExists]
|
|
210
|
+
* @throws {ValidationQueryError} if database query fails
|
|
211
|
+
*
|
|
212
|
+
* @protected
|
|
213
|
+
*/
|
|
214
|
+
async valueExists(value, validatorArguments) {
|
|
215
|
+
var _a3;
|
|
216
|
+
const [entityOrTableName, columnName, dataSourceName, each] = validatorArguments.constraints;
|
|
217
|
+
try {
|
|
218
|
+
const normalizedDataSourceName = dataSourceName && typeof dataSourceName === "string" && dataSourceName.trim() !== "" ? dataSourceName.trim() : void 0;
|
|
219
|
+
const dataSource = await getDataSourceForValidation(
|
|
220
|
+
normalizedDataSourceName
|
|
221
|
+
);
|
|
222
|
+
const repository = typeof entityOrTableName === "string" ? dataSource.getRepository(entityOrTableName) : dataSource.getRepository(entityOrTableName != null ? entityOrTableName : "");
|
|
223
|
+
let queryValue = value;
|
|
224
|
+
if (each && each === true) {
|
|
225
|
+
queryValue = queryValue.split(",").map((v) => v.trim()).filter((v) => v !== "");
|
|
226
|
+
}
|
|
227
|
+
if (Array.isArray(queryValue)) {
|
|
228
|
+
const values = queryValue;
|
|
229
|
+
if (values.length === 0) {
|
|
230
|
+
return [false, false];
|
|
231
|
+
}
|
|
232
|
+
const uniqueValues = Array.from(new Set(values));
|
|
233
|
+
const countResult = await repository.createQueryBuilder("entityOrTableName").select(`COUNT(DISTINCT entityOrTableName.${columnName})`, "cnt").where(`entityOrTableName.${columnName} IN (:...values)`, {
|
|
234
|
+
values: uniqueValues
|
|
235
|
+
}).getRawOne();
|
|
236
|
+
const found = (_a3 = countResult && ("cnt" in countResult ? Number(countResult.cnt) : 0)) != null ? _a3 : 0;
|
|
237
|
+
const anyExists = found > 0;
|
|
238
|
+
const allExists = found === uniqueValues.length;
|
|
239
|
+
return [anyExists, allExists];
|
|
240
|
+
}
|
|
241
|
+
const result = await repository.createQueryBuilder("entityOrTableName").select("1").where(`entityOrTableName.${columnName} = :value`, {
|
|
242
|
+
value: queryValue
|
|
243
|
+
}).take(1).getRawOne();
|
|
244
|
+
const exists = result !== null && result !== void 0;
|
|
245
|
+
return [exists, exists];
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error instanceof ValidationConfigurationError || error instanceof DataSourceNotRegisteredError || error instanceof DataSourceInitializationError || error instanceof DataSourceInvalidError) {
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
251
|
+
if (/no metadata/i.test(errMsg) || /doesn't exist/i.test(errMsg)) {
|
|
252
|
+
const entityName2 = this.getEntityName(entityOrTableName);
|
|
253
|
+
throw new ValidationConfigurationError(
|
|
254
|
+
`No metadata found for "${entityName2}". Ensure it exists and is properly registered in the data source.`,
|
|
255
|
+
{
|
|
256
|
+
property: validatorArguments.property,
|
|
257
|
+
constraints: validatorArguments.constraints
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
262
|
+
const entityName = this.getEntityName(entityOrTableName);
|
|
263
|
+
throw new ValidationQueryError(
|
|
264
|
+
`Failed to validate in ${entityName}.${columnName}`,
|
|
265
|
+
originalError,
|
|
266
|
+
{
|
|
267
|
+
property: validatorArguments.property,
|
|
268
|
+
value,
|
|
269
|
+
entity: entityName,
|
|
270
|
+
columnName
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Extracts the entity name from entity target or table name string.
|
|
277
|
+
*
|
|
278
|
+
* @param entityOrTableName - Entity class or table name
|
|
279
|
+
* @returns The entity name
|
|
280
|
+
*
|
|
281
|
+
* @protected
|
|
282
|
+
*/
|
|
283
|
+
getEntityName(entityOrTableName) {
|
|
284
|
+
return typeof entityOrTableName === "string" ? entityOrTableName : entityOrTableName.name || "entity";
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// src/validators/exists-in.validator.ts
|
|
289
|
+
var import_class_validator = require("class-validator");
|
|
290
|
+
var _ExistsInValidator_decorators, _init, _a;
|
|
291
|
+
_ExistsInValidator_decorators = [(0, import_class_validator.ValidatorConstraint)({ name: "ExistsIn", async: true })];
|
|
292
|
+
var ExistsInValidator = class extends (_a = BaseValidator) {
|
|
293
|
+
/**
|
|
294
|
+
* Validates that the value exists in the specified database column.
|
|
295
|
+
*
|
|
296
|
+
* @param value - The value to validate
|
|
297
|
+
* @param validatorArguments - Validation arguments containing entity/table and column information
|
|
298
|
+
* @returns Promise resolving to true if the value exists, false otherwise
|
|
299
|
+
* @throws {ValidationConfigurationError} if configuration is invalid
|
|
300
|
+
* @throws {ValidationQueryError} if database query fails
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
async validate(value, validatorArguments) {
|
|
305
|
+
if (value === null || value === void 0) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
this.validateConstraints(validatorArguments, "ExistsIn");
|
|
309
|
+
const [anyExists, allExists] = await this.valueExists(
|
|
310
|
+
value,
|
|
311
|
+
validatorArguments
|
|
312
|
+
);
|
|
313
|
+
const each = validatorArguments.constraints[3];
|
|
314
|
+
if (each && each === true) {
|
|
315
|
+
return allExists;
|
|
316
|
+
}
|
|
317
|
+
return anyExists;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Generates the default error message when validation fails.
|
|
321
|
+
*
|
|
322
|
+
* @param validatorArguments - Validation arguments containing column information
|
|
323
|
+
* @returns The formatted error message
|
|
324
|
+
*
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
defaultMessage(validatorArguments) {
|
|
328
|
+
const [entityOrTableName, columnName, _dataSourceName, each] = validatorArguments.constraints;
|
|
329
|
+
const propertyName = validatorArguments.property;
|
|
330
|
+
const entityName = this.getEntityName(entityOrTableName);
|
|
331
|
+
if (each && each === true) {
|
|
332
|
+
return `${propertyName} with values [${validatorArguments.value}] do not all exist in ${entityName}.${columnName}`;
|
|
333
|
+
}
|
|
334
|
+
return `${propertyName} with value "${validatorArguments.value}" does not exist in ${entityName}.${columnName}`;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
_init = __decoratorStart(_a);
|
|
338
|
+
ExistsInValidator = __decorateElement(_init, 0, "ExistsInValidator", _ExistsInValidator_decorators, ExistsInValidator);
|
|
339
|
+
__runInitializers(_init, 1, ExistsInValidator);
|
|
340
|
+
|
|
341
|
+
// src/validators/unique-in.validator.ts
|
|
342
|
+
var import_class_validator2 = require("class-validator");
|
|
343
|
+
var _UniqueInValidator_decorators, _init2, _a2;
|
|
344
|
+
_UniqueInValidator_decorators = [(0, import_class_validator2.ValidatorConstraint)({ name: "UniqueIn", async: true })];
|
|
345
|
+
var UniqueInValidator = class extends (_a2 = BaseValidator) {
|
|
346
|
+
/**
|
|
347
|
+
* Validates that the value is unique in the specified database column.
|
|
348
|
+
*
|
|
349
|
+
* @param value - The value to validate
|
|
350
|
+
* @param validatorArguments - Validation arguments containing entity/table and column information
|
|
351
|
+
* @returns Promise resolving to true if the value is unique, false otherwise
|
|
352
|
+
* @throws {ValidationConfigurationError} if configuration is invalid
|
|
353
|
+
* @throws {ValidationQueryError} if database query fails
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
async validate(value, validatorArguments) {
|
|
358
|
+
if (value === null || value === void 0) {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
this.validateConstraints(validatorArguments, "UniqueIn");
|
|
362
|
+
const [anyExists] = await this.valueExists(value, validatorArguments);
|
|
363
|
+
return !anyExists;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Generates the default error message when validation fails.
|
|
367
|
+
*
|
|
368
|
+
* @param validatorArguments - Validation arguments containing column information
|
|
369
|
+
* @returns The formatted error message
|
|
370
|
+
*
|
|
371
|
+
* @public
|
|
372
|
+
*/
|
|
373
|
+
defaultMessage(validatorArguments) {
|
|
374
|
+
const [entityOrTableName, columnName, _dataSourceName, each] = validatorArguments.constraints;
|
|
375
|
+
const propertyName = validatorArguments.property;
|
|
376
|
+
const entityName = this.getEntityName(entityOrTableName);
|
|
377
|
+
if (each && each === true) {
|
|
378
|
+
return `${propertyName} with values [${validatorArguments.value}] are not all unique in ${entityName}.${columnName}`;
|
|
379
|
+
}
|
|
380
|
+
return `${propertyName} with value "${validatorArguments.value}" is not unique in ${entityName}.${columnName}`;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
_init2 = __decoratorStart(_a2);
|
|
384
|
+
UniqueInValidator = __decorateElement(_init2, 0, "UniqueInValidator", _UniqueInValidator_decorators, UniqueInValidator);
|
|
385
|
+
__runInitializers(_init2, 1, UniqueInValidator);
|
|
386
|
+
|
|
387
|
+
// src/decorators/exists-in.decorator.ts
|
|
388
|
+
function ExistsIn(entityOrTableName, columnName, dataSourceName, validationOptions) {
|
|
389
|
+
return function(object, propertyName) {
|
|
390
|
+
(0, import_class_validator3.registerDecorator)({
|
|
391
|
+
target: object.constructor,
|
|
392
|
+
propertyName,
|
|
393
|
+
options: validationOptions,
|
|
394
|
+
constraints: [
|
|
395
|
+
entityOrTableName,
|
|
396
|
+
columnName,
|
|
397
|
+
dataSourceName,
|
|
398
|
+
validationOptions == null ? void 0 : validationOptions.each
|
|
399
|
+
],
|
|
400
|
+
validator: ExistsInValidator
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/decorators/unique-in.decorator.ts
|
|
406
|
+
var import_class_validator4 = require("class-validator");
|
|
407
|
+
function UniqueIn(entityOrTableName, columnName, dataSourceName, validationOptions) {
|
|
408
|
+
return function(object, propertyName) {
|
|
409
|
+
(0, import_class_validator4.registerDecorator)({
|
|
410
|
+
target: object.constructor,
|
|
411
|
+
propertyName,
|
|
412
|
+
options: validationOptions,
|
|
413
|
+
constraints: [
|
|
414
|
+
entityOrTableName,
|
|
415
|
+
columnName,
|
|
416
|
+
dataSourceName,
|
|
417
|
+
validationOptions == null ? void 0 : validationOptions.each
|
|
418
|
+
],
|
|
419
|
+
validator: UniqueInValidator
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
424
|
+
0 && (module.exports = {
|
|
425
|
+
ExistsIn,
|
|
426
|
+
UniqueIn,
|
|
427
|
+
registerDataSourceForValidation
|
|
428
|
+
});
|
|
429
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors/validator.error.ts","../src/errors/validation-configuration.error.ts","../src/errors/validation-query.error.ts","../src/errors/data-source-initialization.error.ts","../src/errors/data-source-not-registered.error.ts","../src/errors/data-source-invalid.error.ts","../src/utils/data-source.util.ts","../src/decorators/exists-in.decorator.ts","../src/validators/base.validator.ts","../src/validators/exists-in.validator.ts","../src/validators/unique-in.validator.ts","../src/decorators/unique-in.decorator.ts"],"sourcesContent":["export { registerDataSourceForValidation } from '@/utils';\nexport { ExistsIn } from '@/decorators';\nexport { UniqueIn } from '@/decorators';\n","/**\n * Base error class for all validator errors.\n * Preserves the original error stack trace when wrapping errors.\n *\n * @public\n */\nexport class ValidatorError extends Error {\n constructor(\n message: string,\n public readonly cause?: Error,\n ) {\n super(message);\n this.name = this.constructor.name;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n if (cause?.stack) {\n this.stack = `${this.stack}\\nCaused by: ${cause.stack}`;\n }\n }\n}\n","import { ValidatorError } from '@/errors';\n\n/**\n * Error thrown when validation configuration is invalid.\n *\n * @public\n */\nexport class ValidationConfigurationError extends ValidatorError {\n constructor(\n message: string,\n public readonly context?: Record<string, unknown>,\n ) {\n super(message);\n }\n}\n","import { ValidatorError } from '@/errors';\n\n/**\n * Error thrown when a database query fails during validation.\n *\n * @public\n */\nexport class ValidationQueryError extends ValidatorError {\n constructor(\n message: string,\n cause: Error,\n public readonly context?: Record<string, unknown>,\n ) {\n super(message, cause);\n }\n}\n","import { ValidatorError } from '@/errors';\n\n/**\n * Error thrown when data source initialization fails.\n *\n * @public\n */\nexport class DataSourceInitializationError extends ValidatorError {\n constructor(dataSourceName: string, cause?: Error) {\n super(\n `DataSource \"${dataSourceName}\" is not initialized. Please ensure it's initialized before use.`,\n cause,\n );\n }\n}\n","import { ValidatorError } from '@/errors';\n\n/**\n * Error thrown when data source is not registered.\n *\n * @public\n */\nexport class DataSourceNotRegisteredError extends ValidatorError {\n constructor(dataSourceName: string = 'default') {\n super(\n `DataSource \"${dataSourceName}\" is not registered. Please call registerDataSourceForValidation() first.`,\n );\n }\n}\n","import { ValidatorError } from '@/errors';\n\n/**\n * Error thrown when data source is invalid.\n *\n * @public\n */\nexport class DataSourceInvalidError extends ValidatorError {\n constructor(cause?: Error) {\n super(`Invalid DataSource instance provided`, cause);\n }\n}\n","import type { DataSource } from 'typeorm';\n\nimport {\n DataSourceInitializationError,\n DataSourceInvalidError,\n DataSourceNotRegisteredError,\n} from '@/errors';\nimport type { DataSourceLike } from '@/types';\n\nconst dataSources = new Map<string, DataSourceLike>();\nconst DEFAULT_DATA_SOURCE_NAME = 'default';\n\n/**\n * Register a DataSource instance to be used for validation.\n * @param dataSourceInstance - TypeORM DataSource instance\n * @param dataSourceName - Optional DataSource name (defaults to 'default'). If `null`, `undefined`, or an empty string is passed,\n * the registration will use the 'default' name — the same name used when registering without specifying one.\n * @throws {DataSourceInvalidError} if the instance is invalid\n */\nexport function registerDataSourceForValidation(\n dataSourceInstance: DataSourceLike,\n dataSourceName?: string,\n): void {\n if (\n !dataSourceInstance ||\n typeof dataSourceInstance.getRepository !== 'function'\n ) {\n throw new DataSourceInvalidError();\n }\n\n const normalizedName = normalizeDataSourceName(dataSourceName);\n dataSources.set(normalizedName, dataSourceInstance);\n}\n\n/**\n * Get the registered DataSource for validation.\n * @param dataSourceName - DataSource name (defaults to 'default'). Passing `null`, `undefined`, or an empty string will resolve to 'default'.\n * @returns DataSource instance\n * @throws {DataSourceNotRegisteredError} if DataSource is not registered\n * @throws {DataSourceInitializationError} if DataSource fails to initialize\n */\nexport async function getDataSourceForValidation(\n dataSourceName?: string,\n): Promise<DataSource> {\n const normalizedName = normalizeDataSourceName(dataSourceName);\n const dataSource = dataSources.get(normalizedName);\n\n if (!dataSource) {\n throw new DataSourceNotRegisteredError(normalizedName);\n }\n\n if (!dataSource.isInitialized) {\n await dataSource.initialize();\n }\n\n if (!dataSource.isInitialized) {\n throw new DataSourceInitializationError(normalizedName);\n }\n\n return dataSource as DataSource;\n}\n\n/**\n * Clear all registered data sources.\n */\nexport function clearDataSourcesForValidation(): void {\n dataSources.clear();\n}\n\n/**\n * Normalizes and validates the data source name.\n * @param dataSourceName - The data source name to normalize. `null`, `undefined`, or empty string will map to the 'default' name.\n * @returns Normalized data source name\n * @throws {DataSourceInvalidError} if the name is invalid\n */\nfunction normalizeDataSourceName(dataSourceName?: string): string {\n if (dataSourceName === null || dataSourceName === undefined) {\n return DEFAULT_DATA_SOURCE_NAME;\n }\n\n if (typeof dataSourceName !== 'string') {\n throw new DataSourceInvalidError();\n }\n\n const trimmed = dataSourceName.trim();\n\n if (trimmed === '') {\n return DEFAULT_DATA_SOURCE_NAME;\n }\n\n return trimmed;\n}\n","import { type ValidationOptions, registerDecorator } from 'class-validator';\nimport type { EntityTarget } from 'typeorm';\n\nimport { ExistsInValidator } from '@/validators';\n\n/**\n * Validates that the decorated property's value **exists in** a specific database column.\n *\n * @description\n * The `@ExistsIn` decorator performs a database lookup (via TypeORM) to verify that the\n * provided value **exists** in the specified table column.\n * It supports both:\n * - **Entity classes** (e.g., `User`, `Post`)\n * - **Table name strings** (e.g., `'user'`, `'post'`)\n *\n *\n * You can also specify which registered data source to use by passing the dataSourceName\n * (the same name you used when calling `registerDataSourceForValidation(dataSourceInstance, 'yourName')`).\n * If you pass `null` or `undefined` (or leave the parameter omitted), the decorator will use the\n * 'default' data source — the same default used when registering a data source without specifying a name.\n *\n * The `validationOptions` parameter accepts the same ValidationOptions used by `class-validator`.\n * Therefore options such as `each: true` (to validate array elements) and `message` (to provide a custom error message)\n * behave exactly as they do in `class-validator`.\n *\n * @example\n * **Using with an Entity class:**\n * ```typescript\n * class CreatePostDto {\n * @ExistsIn(User, 'id')\n * authorId: number;\n * }\n * ```\n *\n * @example\n * **Using with a table name:**\n * ```typescript\n * class CreatePostDto {\n * @ExistsIn('user', 'id')\n * authorId: number;\n * }\n * ```\n *\n * @example\n * **Using with a specific data source (registered as 'secondary'):**\n * ```typescript\n * class CreatePostDto {\n * @ExistsIn(User, 'id', 'secondary')\n * authorId: number;\n * }\n * ```\n *\n * @example\n * **Using a default data source and validating arrays with custom message:**\n * ```typescript\n * class CreateMultiplePostsDto {\n * @ExistsIn('user', 'id', null, { each: true, message: 'Every authorId must exist' })\n * authorIds: number[];\n * }\n * ```\n *\n * @param entityOrTableName - The entity class or table name to check against.\n * @param columnName - The column name in which to look for the value.\n * @param dataSourceName - Optional name of the data source to use for validation (must match a registered name).\n * Passing `null`/`undefined` (or omitting this argument) will use the 'default' data source.\n * @param validationOptions - Optional validation settings from `class-validator` (use `{ each: true }` for arrays and `message` for custom text).\n * @returns A property decorator function used by `class-validator`.\n *\n * @public\n */\nexport function ExistsIn<T extends EntityTarget<unknown> | string>(\n entityOrTableName: T,\n columnName: T extends string\n ? string\n : T extends EntityTarget<infer E>\n ? keyof E & string\n : string,\n dataSourceName?: string,\n validationOptions?: ValidationOptions,\n): PropertyDecorator {\n return function (object: object, propertyName: string | symbol): void {\n registerDecorator({\n target: object.constructor,\n propertyName: propertyName as string,\n options: validationOptions,\n constraints: [\n entityOrTableName,\n columnName,\n dataSourceName,\n validationOptions?.each,\n ] as const,\n validator: ExistsInValidator,\n });\n };\n}\n","import type {\n DataSource,\n EntityTarget,\n ObjectLiteral,\n Repository,\n} from 'typeorm';\n\nimport {\n DataSourceInitializationError,\n DataSourceInvalidError,\n DataSourceNotRegisteredError,\n ValidationConfigurationError,\n ValidationQueryError,\n} from '@/errors';\nimport type { BaseValidatorArguments } from '@/types';\nimport { getDataSourceForValidation } from '@/utils';\n\n/**\n * Base validator.\n *\n * @description\n * Provides common functionality for validators,\n * including data source management, error handling, and entity name resolution.\n *\n * @abstract\n * @public\n */\nexport abstract class BaseValidator {\n /**\n * Validates the configuration constraints.\n *\n * @param validatorArguments - Validation arguments\n * @throws {ValidationConfigurationError} if constraints are invalid\n *\n * @protected\n */\n protected validateConstraints(\n validatorArguments: BaseValidatorArguments,\n validatorName: string,\n ): void {\n const [entityOrTableName, columnName] = validatorArguments.constraints;\n\n if (!entityOrTableName || !columnName) {\n throw new ValidationConfigurationError(\n `${validatorName}: entity/table name and column name are required`,\n {\n property: validatorArguments.property,\n constraints: validatorArguments.constraints,\n },\n );\n }\n }\n\n /**\n * Executes a database query to check for value existence.\n *\n * Returns a tuple: [anyExists, allExists]\n * - anyExists: true if at least one of the provided values exists\n * - allExists: true if all of the provided values exist\n *\n * For single values both flags are identical.\n *\n * @param value - The value to query\n * @param validatorArguments - Validator arguments\n * @returns Promise resolving to [anyExists, allExists]\n * @throws {ValidationQueryError} if database query fails\n *\n * @protected\n */\n protected async valueExists(\n value: unknown,\n validatorArguments: BaseValidatorArguments,\n ): Promise<[boolean, boolean]> {\n const [entityOrTableName, columnName, dataSourceName, each] =\n validatorArguments.constraints;\n\n try {\n const normalizedDataSourceName =\n dataSourceName &&\n typeof dataSourceName === 'string' &&\n dataSourceName.trim() !== ''\n ? dataSourceName.trim()\n : undefined;\n\n const dataSource: DataSource = await getDataSourceForValidation(\n normalizedDataSourceName,\n );\n\n const repository: Repository<ObjectLiteral> =\n typeof entityOrTableName === 'string'\n ? dataSource.getRepository(entityOrTableName)\n : dataSource.getRepository(entityOrTableName ?? '');\n\n let queryValue: unknown = value;\n if (each && each === true) {\n queryValue = (queryValue as string)\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '');\n }\n\n // Array-value path\n if (Array.isArray(queryValue)) {\n const values = queryValue as unknown[];\n if (values.length === 0) {\n return [false, false];\n }\n\n const uniqueValues = Array.from(new Set(values));\n\n const countResult = await repository\n .createQueryBuilder('entityOrTableName')\n .select(`COUNT(DISTINCT entityOrTableName.${columnName})`, 'cnt')\n .where(`entityOrTableName.${columnName} IN (:...values)`, {\n values: uniqueValues,\n })\n .getRawOne<{ cnt: string | number }>();\n\n const found =\n (countResult &&\n ('cnt' in countResult ? Number(countResult.cnt) : 0)) ??\n 0;\n\n const anyExists = found > 0;\n const allExists = found === uniqueValues.length;\n\n return [anyExists, allExists];\n }\n\n // Single-value path\n const result: { '1': number } | null | undefined = await repository\n .createQueryBuilder('entityOrTableName')\n .select('1')\n .where(`entityOrTableName.${columnName} = :value`, {\n value: queryValue,\n })\n .take(1)\n .getRawOne<{ '1': number }>();\n\n const exists = result !== null && result !== undefined;\n return [exists, exists];\n } catch (error) {\n if (\n error instanceof ValidationConfigurationError ||\n error instanceof DataSourceNotRegisteredError ||\n error instanceof DataSourceInitializationError ||\n error instanceof DataSourceInvalidError\n ) {\n throw error;\n }\n const errMsg = error instanceof Error ? error.message : String(error);\n\n if (/no metadata/i.test(errMsg) || /doesn't exist/i.test(errMsg)) {\n const entityName = this.getEntityName(entityOrTableName);\n throw new ValidationConfigurationError(\n `No metadata found for \"${entityName}\". Ensure it exists and is properly registered in the data source.`,\n {\n property: validatorArguments.property,\n constraints: validatorArguments.constraints,\n },\n );\n }\n const originalError =\n error instanceof Error ? error : new Error(String(error));\n\n const entityName = this.getEntityName(entityOrTableName);\n\n throw new ValidationQueryError(\n `Failed to validate in ${entityName}.${columnName}`,\n originalError,\n {\n property: validatorArguments.property,\n value,\n entity: entityName,\n columnName: columnName,\n },\n );\n }\n }\n\n /**\n * Extracts the entity name from entity target or table name string.\n *\n * @param entityOrTableName - Entity class or table name\n * @returns The entity name\n *\n * @protected\n */\n protected getEntityName(\n entityOrTableName: EntityTarget<ObjectLiteral> | string,\n ): string {\n return typeof entityOrTableName === 'string'\n ? entityOrTableName\n : (entityOrTableName as { name?: string }).name || 'entity';\n }\n}\n","import {\n ValidatorConstraint,\n type ValidatorConstraintInterface,\n} from 'class-validator';\n\nimport type { BaseValidatorArguments } from '@/types';\nimport { BaseValidator } from '@/validators';\n\n/**\n * Validator that checks if a value exists in a database table column.\n *\n * @description\n * This validator performs an asynchronous database query to verify the existence\n * of a value in the specified column. Used internally by the ExistsIn decorator.\n *\n * @public\n */\n@ValidatorConstraint({ name: 'ExistsIn', async: true })\nexport class ExistsInValidator\n extends BaseValidator\n implements ValidatorConstraintInterface\n{\n /**\n * Validates that the value exists in the specified database column.\n *\n * @param value - The value to validate\n * @param validatorArguments - Validation arguments containing entity/table and column information\n * @returns Promise resolving to true if the value exists, false otherwise\n * @throws {ValidationConfigurationError} if configuration is invalid\n * @throws {ValidationQueryError} if database query fails\n *\n * @public\n */\n async validate(\n value: unknown,\n validatorArguments: BaseValidatorArguments,\n ): Promise<boolean> {\n if (value === null || value === undefined) {\n return false;\n }\n\n this.validateConstraints(validatorArguments, 'ExistsIn');\n\n const [anyExists, allExists] = await this.valueExists(\n value,\n validatorArguments,\n );\n\n const each = validatorArguments.constraints[3];\n if (each && each === true) {\n return allExists;\n }\n return anyExists;\n }\n /**\n * Generates the default error message when validation fails.\n *\n * @param validatorArguments - Validation arguments containing column information\n * @returns The formatted error message\n *\n * @public\n */\n defaultMessage(validatorArguments: BaseValidatorArguments): string {\n const [entityOrTableName, columnName, _dataSourceName, each] =\n validatorArguments.constraints;\n const propertyName = validatorArguments.property;\n const entityName = this.getEntityName(entityOrTableName);\n\n if (each && each === true) {\n return `${propertyName} with values [${validatorArguments.value}] do not all exist in ${entityName}.${columnName}`;\n }\n\n return `${propertyName} with value \"${validatorArguments.value}\" does not exist in ${entityName}.${columnName}`;\n }\n}\n","import {\n ValidatorConstraint,\n type ValidatorConstraintInterface,\n} from 'class-validator';\n\nimport type { BaseValidatorArguments } from '@/types';\nimport { BaseValidator } from '@/validators';\n\n/**\n * Validator that checks if a value is unique in a database table column.\n *\n * @description\n * This validator performs an asynchronous database query to verify the uniqueness\n * of a value in the specified column. Used internally by the UniqueIn decorator.\n *\n * @public\n */\n@ValidatorConstraint({ name: 'UniqueIn', async: true })\nexport class UniqueInValidator\n extends BaseValidator\n implements ValidatorConstraintInterface\n{\n /**\n * Validates that the value is unique in the specified database column.\n *\n * @param value - The value to validate\n * @param validatorArguments - Validation arguments containing entity/table and column information\n * @returns Promise resolving to true if the value is unique, false otherwise\n * @throws {ValidationConfigurationError} if configuration is invalid\n * @throws {ValidationQueryError} if database query fails\n *\n * @public\n */\n async validate(\n value: unknown,\n validatorArguments: BaseValidatorArguments,\n ): Promise<boolean> {\n if (value === null || value === undefined) {\n return true;\n }\n\n this.validateConstraints(validatorArguments, 'UniqueIn');\n\n const [anyExists] = await this.valueExists(value, validatorArguments);\n return !anyExists;\n }\n\n /**\n * Generates the default error message when validation fails.\n *\n * @param validatorArguments - Validation arguments containing column information\n * @returns The formatted error message\n *\n * @public\n */\n defaultMessage(validatorArguments: BaseValidatorArguments): string {\n const [entityOrTableName, columnName, _dataSourceName, each] =\n validatorArguments.constraints;\n const propertyName = validatorArguments.property;\n const entityName = this.getEntityName(entityOrTableName);\n\n if (each && each === true) {\n return `${propertyName} with values [${validatorArguments.value}] are not all unique in ${entityName}.${columnName}`;\n }\n\n return `${propertyName} with value \"${validatorArguments.value}\" is not unique in ${entityName}.${columnName}`;\n }\n}\n","import { type ValidationOptions, registerDecorator } from 'class-validator';\nimport type { EntityTarget } from 'typeorm';\n\nimport { UniqueInValidator } from '@/validators';\n\n/**\n * Validates that the decorated property's value is **unique** within a specified database column.\n *\n * @description\n * The `@UniqueIn` decorator performs a database lookup (via TypeORM) to ensure that the provided\n * value does **not already exist** in the specified table column.\n * It supports both:\n * - **Entity class references** (e.g., `User`, `Post`)\n * - **Direct table name strings** (e.g., `'user'`, `'post'`)\n *\n *\n * You can also specify which registered data source to use by passing the dataSourceName\n * (the same name you used when calling `registerDataSourceForValidation(dataSourceInstance, 'yourName')`).\n * If you pass `null` or `undefined` (or leave the parameter omitted), the decorator will use the\n * 'default' data source — the same default used when registering a data source without specifying a name.\n *\n * The `validationOptions` parameter accepts the same ValidationOptions used by `class-validator`.\n * Therefore options such as `each: true` (to validate array elements) and `message` (to provide a custom error message)\n * behave exactly as they do in `class-validator`.\n *\n * @example\n * **Using with an Entity class:**\n * ```typescript\n * class CreateUserDto {\n * @UniqueIn(User, 'email')\n * email: string;\n * }\n * ```\n *\n * @example\n * **Using with a table name:**\n * ```typescript\n * class CreateUserDto {\n * @UniqueIn('user', 'email')\n * email: string;\n * }\n * ```\n *\n * @example\n * **Using with a specific data source (registered as 'secondary'):**\n * ```typescript\n * class CreateUserDto {\n * @UniqueIn(User, 'email', 'secondary')\n * email: string;\n * }\n * ```\n *\n * @example\n * **Using a default data source and validating arrays with custom message:**\n * ```typescript\n * class CreateUsersDto {\n * @UniqueIn('user', 'email', null, { each: true, message: 'Each user email must be unique' })\n * emails: string[];\n * }\n * ```\n *\n * @param entityOrTableName - The entity class or table name to check against.\n * @param columnName - The column name to validate uniqueness in.\n * @param dataSourceName - Optional name of the data source to use for validation (must match a registered name).\n * Passing `null`/`undefined` (or omitting this argument) will use the 'default' data source.\n * @param validationOptions - Optional validation settings from `class-validator` (use `{ each: true }` for arrays and `message` for custom text).\n * @returns A property decorator function used by `class-validator`.\n *\n * @public\n */\nexport function UniqueIn<T extends EntityTarget<unknown> | string>(\n entityOrTableName: T,\n columnName: T extends string\n ? string\n : T extends EntityTarget<infer E>\n ? keyof E & string\n : string,\n dataSourceName?: string,\n validationOptions?: ValidationOptions,\n): PropertyDecorator {\n return function (object: object, propertyName: string | symbol): void {\n registerDecorator({\n target: object.constructor,\n propertyName: propertyName as string,\n options: validationOptions,\n constraints: [\n entityOrTableName,\n columnName,\n dataSourceName,\n validationOptions?.each,\n ] as const,\n validator: UniqueInValidator,\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,iBAAN,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;AAjDOD,SAAA,iBAAAC;AAAM,oBAAN,kBAAAD,QAAA,wBADP,+BACa;AAAN,kBAAAA,QAAA,GAAM;;;AHoDN,SAAS,SACd,mBACA,YAKA,gBACA,mBACmB;AACnB,SAAO,SAAU,QAAgB,cAAqC;AACpE,mDAAkB;AAAA,MAChB,QAAQ,OAAO;AAAA,MACf;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,uDAAmB;AAAA,MACrB;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;;;AI9FA,IAAAE,0BAA0D;AAsEnD,SAAS,SACd,mBACA,YAKA,gBACA,mBACmB;AACnB,SAAO,SAAU,QAAgB,cAAqC;AACpE,mDAAkB;AAAA,MAChB,QAAQ,OAAO;AAAA,MACf;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,uDAAmB;AAAA,MACrB;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;","names":["import_class_validator","_a","entityName","import_class_validator","_init","_a","import_class_validator"]}
|