@fluojs/validation 1.0.5 → 1.0.6
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.ko.md +26 -0
- package/README.md +26 -0
- package/dist/decorators.d.ts +67 -67
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +67 -130
- package/dist/internal/decorator-factories.d.ts +12 -0
- package/dist/internal/decorator-factories.d.ts.map +1 -0
- package/dist/internal/decorator-factories.js +32 -0
- package/dist/internal/decorator-metadata.d.ts +7 -0
- package/dist/internal/decorator-metadata.d.ts.map +1 -0
- package/dist/internal/decorator-metadata.js +38 -0
- package/dist/internal/dto-metadata-cache.d.ts +17 -0
- package/dist/internal/dto-metadata-cache.d.ts.map +1 -0
- package/dist/internal/dto-metadata-cache.js +48 -0
- package/dist/internal/object-utils.d.ts +4 -0
- package/dist/internal/object-utils.d.ts.map +1 -0
- package/dist/internal/object-utils.js +25 -0
- package/dist/internal/rule-handlers.d.ts +19 -0
- package/dist/internal/rule-handlers.d.ts.map +1 -0
- package/dist/internal/rule-handlers.js +209 -0
- package/dist/internal/validator-js-adapter.d.ts +5 -0
- package/dist/internal/validator-js-adapter.d.ts.map +1 -0
- package/dist/internal/validator-js-adapter.js +88 -0
- package/dist/mapped-types.d.ts +1 -1
- package/dist/mapped-types.d.ts.map +1 -1
- package/dist/mapped-types.js +1 -1
- package/dist/standard-schema.d.ts +1 -1
- package/dist/standard-schema.d.ts.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +9 -373
- package/package.json +2 -2
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":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AACH,eAAO,MAAM,YAAY,2EAAwH,CAAC;AAClJ;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,2EAAwH,CAAC;AAElJ;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,iBAAiB,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,0BAA0B,EAC9E,OAAO,CAAC,EAAE,0BAA0B,GACnC,gBAAgB,CAKlB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,gCAAgC,GAAG,gBAAgB,CASrH;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAUlH"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,81 +1,17 @@
|
|
|
1
|
+
import { createArrayValidationDecorator, createFlagValidationDecorator, createValidationDecorator, createValidationOptionsWithConfigDecorator, createValidatorJsDecorator } from './internal/decorator-factories.js';
|
|
2
|
+
import { appendStandardClassValidationRule } from './internal/decorator-metadata.js';
|
|
1
3
|
import { createClassValidatorFromStandardSchema, isStandardSchemaLike } from './standard-schema.js';
|
|
2
|
-
const standardDtoValidationMetadataKey = Symbol.for('fluo.standard.dto-validation');
|
|
3
|
-
const standardClassValidationMetadataKey = Symbol.for('fluo.standard.class-validation');
|
|
4
|
-
function getStandardMetadataBag(metadata) {
|
|
5
|
-
if (metadata === null || metadata === undefined) {
|
|
6
|
-
throw new Error('Decorator metadata is not available. Ensure your environment supports TC39 decorator metadata (Stage 3).');
|
|
7
|
-
}
|
|
8
|
-
return metadata;
|
|
9
|
-
}
|
|
10
|
-
function getStandardDtoValidationMap(metadata) {
|
|
11
|
-
const bag = getStandardMetadataBag(metadata);
|
|
12
|
-
const current = bag[standardDtoValidationMetadataKey];
|
|
13
|
-
if (current) {
|
|
14
|
-
return current;
|
|
15
|
-
}
|
|
16
|
-
const created = new Map();
|
|
17
|
-
bag[standardDtoValidationMetadataKey] = created;
|
|
18
|
-
return created;
|
|
19
|
-
}
|
|
20
|
-
function getStandardClassValidationList(metadata) {
|
|
21
|
-
const bag = getStandardMetadataBag(metadata);
|
|
22
|
-
const current = bag[standardClassValidationMetadataKey];
|
|
23
|
-
if (current) {
|
|
24
|
-
return current;
|
|
25
|
-
}
|
|
26
|
-
const created = [];
|
|
27
|
-
bag[standardClassValidationMetadataKey] = created;
|
|
28
|
-
return created;
|
|
29
|
-
}
|
|
30
|
-
function appendStandardDtoValidationRule(metadata, propertyKey, rule) {
|
|
31
|
-
const map = getStandardDtoValidationMap(metadata);
|
|
32
|
-
map.set(propertyKey, [...(map.get(propertyKey) ?? []), rule]);
|
|
33
|
-
}
|
|
34
|
-
function appendStandardClassValidationRule(metadata, rule) {
|
|
35
|
-
getStandardClassValidationList(metadata).push(rule);
|
|
36
|
-
}
|
|
37
4
|
function resolveClassValidator(validate) {
|
|
38
5
|
if (!isStandardSchemaLike(validate)) {
|
|
39
6
|
return validate;
|
|
40
7
|
}
|
|
41
8
|
return createClassValidatorFromStandardSchema(validate);
|
|
42
9
|
}
|
|
43
|
-
function createValidationDecorator(ruleFactory) {
|
|
44
|
-
const decorator = (_value, context) => {
|
|
45
|
-
appendStandardDtoValidationRule(context.metadata, context.name, ruleFactory());
|
|
46
|
-
};
|
|
47
|
-
return decorator;
|
|
48
|
-
}
|
|
49
|
-
function createValidationOptionsWithConfigDecorator(ruleFactory) {
|
|
50
|
-
return (value, options) => {
|
|
51
|
-
return createValidationDecorator(() => ruleFactory(value, options));
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function createFlagValidationDecorator(ruleFactory) {
|
|
55
|
-
return options => {
|
|
56
|
-
return createValidationDecorator(() => ruleFactory(options));
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function createArrayValidationDecorator(ruleFactory) {
|
|
60
|
-
return (values, options) => {
|
|
61
|
-
return createValidationDecorator(() => ruleFactory(values, options));
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function createValidatorJsDecorator(validator) {
|
|
65
|
-
return (args, options) => {
|
|
66
|
-
return createValidationDecorator(() => ({
|
|
67
|
-
args,
|
|
68
|
-
kind: 'validatorjs',
|
|
69
|
-
validator,
|
|
70
|
-
...options
|
|
71
|
-
}));
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
10
|
|
|
75
11
|
/**
|
|
76
12
|
* Validates that the decorated field is a string value.
|
|
77
13
|
*
|
|
78
|
-
* @param options Optional validation behavior (`message`, `
|
|
14
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
79
15
|
* @returns A field decorator that registers a string validation rule.
|
|
80
16
|
*/
|
|
81
17
|
export function IsString(options) {
|
|
@@ -88,7 +24,7 @@ export function IsString(options) {
|
|
|
88
24
|
/**
|
|
89
25
|
* Validates that the decorated field is a number value.
|
|
90
26
|
*
|
|
91
|
-
* @param options Optional validation behavior (`message`, `
|
|
27
|
+
* @param options Optional validation behavior (`message`, `code`, `each`, `allowNaN`).
|
|
92
28
|
* @returns A field decorator that registers a number validation rule.
|
|
93
29
|
*/
|
|
94
30
|
export function IsNumber(options) {
|
|
@@ -101,7 +37,7 @@ export function IsNumber(options) {
|
|
|
101
37
|
/**
|
|
102
38
|
* Validates that the decorated field is a boolean value.
|
|
103
39
|
*
|
|
104
|
-
* @param options Optional validation behavior (`message`, `
|
|
40
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
105
41
|
* @returns A field decorator that registers a boolean validation rule.
|
|
106
42
|
*/
|
|
107
43
|
export function IsBoolean(options) {
|
|
@@ -115,7 +51,7 @@ export function IsBoolean(options) {
|
|
|
115
51
|
* Applies subsequent validators only when the condition returns `true`.
|
|
116
52
|
*
|
|
117
53
|
* @param validateIf Predicate that decides whether subsequent validators should run.
|
|
118
|
-
* @param options Optional validation behavior (`message`, `
|
|
54
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
119
55
|
* @returns A field decorator that adds conditional validation execution.
|
|
120
56
|
*/
|
|
121
57
|
export const ValidateIf = (validateIf, options) => createValidationDecorator(() => ({
|
|
@@ -127,7 +63,7 @@ export const ValidateIf = (validateIf, options) => createValidationDecorator(()
|
|
|
127
63
|
/**
|
|
128
64
|
* Validates that the decorated field is neither `null` nor `undefined`.
|
|
129
65
|
*
|
|
130
|
-
* @param options Optional validation behavior (`message`, `
|
|
66
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
131
67
|
* @returns A field decorator that registers a required-value rule.
|
|
132
68
|
*/
|
|
133
69
|
export const IsDefined = createFlagValidationDecorator(options => ({
|
|
@@ -137,7 +73,7 @@ export const IsDefined = createFlagValidationDecorator(options => ({
|
|
|
137
73
|
/**
|
|
138
74
|
* Skips subsequent validators when the decorated field is `null` or `undefined`.
|
|
139
75
|
*
|
|
140
|
-
* @param options Optional validation behavior (`message`, `
|
|
76
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
141
77
|
* @returns A field decorator that registers optional-value semantics.
|
|
142
78
|
*/
|
|
143
79
|
export const IsOptional = createFlagValidationDecorator(options => ({
|
|
@@ -148,7 +84,7 @@ export const IsOptional = createFlagValidationDecorator(options => ({
|
|
|
148
84
|
* Validates that the decorated field strictly equals the expected value.
|
|
149
85
|
*
|
|
150
86
|
* @param value Expected value to compare against the field value.
|
|
151
|
-
* @param options Optional validation behavior (`message`, `
|
|
87
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
152
88
|
* @returns A field decorator that registers an equality rule.
|
|
153
89
|
*/
|
|
154
90
|
export const Equals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -160,7 +96,7 @@ export const Equals = createValidationOptionsWithConfigDecorator((value, options
|
|
|
160
96
|
* Validates that the decorated field does not strictly equal the forbidden value.
|
|
161
97
|
*
|
|
162
98
|
* @param value Forbidden value to compare against the field value.
|
|
163
|
-
* @param options Optional validation behavior (`message`, `
|
|
99
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
164
100
|
* @returns A field decorator that registers an inequality rule.
|
|
165
101
|
*/
|
|
166
102
|
export const NotEquals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -171,7 +107,7 @@ export const NotEquals = createValidationOptionsWithConfigDecorator((value, opti
|
|
|
171
107
|
/**
|
|
172
108
|
* Validates that the decorated field is empty.
|
|
173
109
|
*
|
|
174
|
-
* @param options Optional validation behavior (`message`, `
|
|
110
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
175
111
|
* @returns A field decorator that registers an empty-value rule.
|
|
176
112
|
*/
|
|
177
113
|
export const IsEmpty = createFlagValidationDecorator(options => ({
|
|
@@ -181,7 +117,7 @@ export const IsEmpty = createFlagValidationDecorator(options => ({
|
|
|
181
117
|
/**
|
|
182
118
|
* Validates that the decorated field is not empty.
|
|
183
119
|
*
|
|
184
|
-
* @param options Optional validation behavior (`message`, `
|
|
120
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
185
121
|
* @returns A field decorator that registers a non-empty-value rule.
|
|
186
122
|
*/
|
|
187
123
|
export const IsNotEmpty = createFlagValidationDecorator(options => ({
|
|
@@ -192,7 +128,7 @@ export const IsNotEmpty = createFlagValidationDecorator(options => ({
|
|
|
192
128
|
* Validates that the decorated field is included in the accepted values.
|
|
193
129
|
*
|
|
194
130
|
* @param values Accepted values for the field.
|
|
195
|
-
* @param options Optional validation behavior (`message`, `
|
|
131
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
196
132
|
* @returns A field decorator that registers an inclusion rule.
|
|
197
133
|
*/
|
|
198
134
|
export const IsIn = createArrayValidationDecorator((values, options) => ({
|
|
@@ -204,7 +140,7 @@ export const IsIn = createArrayValidationDecorator((values, options) => ({
|
|
|
204
140
|
* Validates that the decorated field is not included in the rejected values.
|
|
205
141
|
*
|
|
206
142
|
* @param values Rejected values for the field.
|
|
207
|
-
* @param options Optional validation behavior (`message`, `
|
|
143
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
208
144
|
* @returns A field decorator that registers an exclusion rule.
|
|
209
145
|
*/
|
|
210
146
|
export const IsNotIn = createArrayValidationDecorator((values, options) => ({
|
|
@@ -215,7 +151,7 @@ export const IsNotIn = createArrayValidationDecorator((values, options) => ({
|
|
|
215
151
|
/**
|
|
216
152
|
* Validates that the decorated field is a `Date` value.
|
|
217
153
|
*
|
|
218
|
-
* @param options Optional validation behavior (`message`, `
|
|
154
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
219
155
|
* @returns A field decorator that registers a date validation rule.
|
|
220
156
|
*/
|
|
221
157
|
export const IsDate = createFlagValidationDecorator(options => ({
|
|
@@ -225,7 +161,7 @@ export const IsDate = createFlagValidationDecorator(options => ({
|
|
|
225
161
|
/**
|
|
226
162
|
* Validates that the decorated field is an array.
|
|
227
163
|
*
|
|
228
|
-
* @param options Optional validation behavior (`message`, `
|
|
164
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
229
165
|
* @returns A field decorator that registers an array validation rule.
|
|
230
166
|
*/
|
|
231
167
|
export const IsArray = createFlagValidationDecorator(options => ({
|
|
@@ -235,7 +171,7 @@ export const IsArray = createFlagValidationDecorator(options => ({
|
|
|
235
171
|
/**
|
|
236
172
|
* Validates that the decorated field is an object value.
|
|
237
173
|
*
|
|
238
|
-
* @param options Optional validation behavior (`message`, `
|
|
174
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
239
175
|
* @returns A field decorator that registers an object validation rule.
|
|
240
176
|
*/
|
|
241
177
|
export const IsObject = createFlagValidationDecorator(options => ({
|
|
@@ -245,7 +181,7 @@ export const IsObject = createFlagValidationDecorator(options => ({
|
|
|
245
181
|
/**
|
|
246
182
|
* Validates that the decorated field is an integer.
|
|
247
183
|
*
|
|
248
|
-
* @param options Optional validation behavior (`message`, `
|
|
184
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
249
185
|
* @returns A field decorator that registers an integer validation rule.
|
|
250
186
|
*/
|
|
251
187
|
export const IsInt = createFlagValidationDecorator(options => ({
|
|
@@ -255,7 +191,7 @@ export const IsInt = createFlagValidationDecorator(options => ({
|
|
|
255
191
|
/**
|
|
256
192
|
* Validates that the decorated field is a positive number.
|
|
257
193
|
*
|
|
258
|
-
* @param options Optional validation behavior (`message`, `
|
|
194
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
259
195
|
* @returns A field decorator that registers a positive-number rule.
|
|
260
196
|
*/
|
|
261
197
|
export const IsPositive = createFlagValidationDecorator(options => ({
|
|
@@ -265,7 +201,7 @@ export const IsPositive = createFlagValidationDecorator(options => ({
|
|
|
265
201
|
/**
|
|
266
202
|
* Validates that the decorated field is a negative number.
|
|
267
203
|
*
|
|
268
|
-
* @param options Optional validation behavior (`message`, `
|
|
204
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
269
205
|
* @returns A field decorator that registers a negative-number rule.
|
|
270
206
|
*/
|
|
271
207
|
export const IsNegative = createFlagValidationDecorator(options => ({
|
|
@@ -277,7 +213,7 @@ export const IsNegative = createFlagValidationDecorator(options => ({
|
|
|
277
213
|
* Validates that the field value is included in the given enum-like set.
|
|
278
214
|
*
|
|
279
215
|
* @param values Enum object or literal value list that defines the accepted set.
|
|
280
|
-
* @param options Optional validation behavior (`message`, `
|
|
216
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
281
217
|
* @returns A field decorator that registers an enum-membership rule.
|
|
282
218
|
*/
|
|
283
219
|
export function IsEnum(values, options) {
|
|
@@ -293,7 +229,7 @@ export function IsEnum(values, options) {
|
|
|
293
229
|
* Validates that the decorated field is divisible by the given divisor.
|
|
294
230
|
*
|
|
295
231
|
* @param value Divisor used for the numeric divisibility check.
|
|
296
|
-
* @param options Optional validation behavior (`message`, `
|
|
232
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
297
233
|
* @returns A field decorator that registers a divisibility rule.
|
|
298
234
|
*/
|
|
299
235
|
export const IsDivisibleBy = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -305,7 +241,7 @@ export const IsDivisibleBy = createValidationOptionsWithConfigDecorator((value,
|
|
|
305
241
|
* Validates that the decorated field is greater than or equal to the minimum.
|
|
306
242
|
*
|
|
307
243
|
* @param value Inclusive minimum allowed numeric value.
|
|
308
|
-
* @param options Optional validation behavior (`message`, `
|
|
244
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
309
245
|
* @returns A field decorator that registers a minimum-value rule.
|
|
310
246
|
*/
|
|
311
247
|
export const Min = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -317,7 +253,7 @@ export const Min = createValidationOptionsWithConfigDecorator((value, options) =
|
|
|
317
253
|
* Validates that the decorated field is less than or equal to the maximum.
|
|
318
254
|
*
|
|
319
255
|
* @param value Inclusive maximum allowed numeric value.
|
|
320
|
-
* @param options Optional validation behavior (`message`, `
|
|
256
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
321
257
|
* @returns A field decorator that registers a maximum-value rule.
|
|
322
258
|
*/
|
|
323
259
|
export const Max = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -329,7 +265,7 @@ export const Max = createValidationOptionsWithConfigDecorator((value, options) =
|
|
|
329
265
|
* Validates that the decorated field is on or after the minimum date.
|
|
330
266
|
*
|
|
331
267
|
* @param value Inclusive minimum allowed date.
|
|
332
|
-
* @param options Optional validation behavior (`message`, `
|
|
268
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
333
269
|
* @returns A field decorator that registers a minimum-date rule.
|
|
334
270
|
*/
|
|
335
271
|
export const MinDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -341,7 +277,7 @@ export const MinDate = createValidationOptionsWithConfigDecorator((value, option
|
|
|
341
277
|
* Validates that the decorated field is on or before the maximum date.
|
|
342
278
|
*
|
|
343
279
|
* @param value Inclusive maximum allowed date.
|
|
344
|
-
* @param options Optional validation behavior (`message`, `
|
|
280
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
345
281
|
* @returns A field decorator that registers a maximum-date rule.
|
|
346
282
|
*/
|
|
347
283
|
export const MaxDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -353,7 +289,7 @@ export const MaxDate = createValidationOptionsWithConfigDecorator((value, option
|
|
|
353
289
|
* Validates that the decorated field contains the required substring.
|
|
354
290
|
*
|
|
355
291
|
* @param value Required substring.
|
|
356
|
-
* @param options Optional validation behavior (`message`, `
|
|
292
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
357
293
|
* @returns A field decorator that registers a substring-presence rule.
|
|
358
294
|
*/
|
|
359
295
|
export const Contains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -365,7 +301,7 @@ export const Contains = createValidationOptionsWithConfigDecorator((value, optio
|
|
|
365
301
|
* Validates that the decorated field does not contain the forbidden substring.
|
|
366
302
|
*
|
|
367
303
|
* @param value Forbidden substring.
|
|
368
|
-
* @param options Optional validation behavior (`message`, `
|
|
304
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
369
305
|
* @returns A field decorator that registers a substring-exclusion rule.
|
|
370
306
|
*/
|
|
371
307
|
export const NotContains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -379,7 +315,7 @@ export const NotContains = createValidationOptionsWithConfigDecorator((value, op
|
|
|
379
315
|
*
|
|
380
316
|
* @param min Minimum inclusive length.
|
|
381
317
|
* @param max Optional maximum inclusive length.
|
|
382
|
-
* @param options Optional validation behavior (`message`, `
|
|
318
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
383
319
|
* @returns A field decorator that registers a bounded-length rule.
|
|
384
320
|
*/
|
|
385
321
|
export function Length(min, max, options) {
|
|
@@ -393,9 +329,10 @@ export function Length(min, max, options) {
|
|
|
393
329
|
|
|
394
330
|
/**
|
|
395
331
|
* Validates a nested DTO instance using the provided constructor.
|
|
332
|
+
* Arrays, Sets, and Maps are traversed automatically without requiring `each`.
|
|
396
333
|
*
|
|
397
334
|
* @param dto DTO constructor (or lazy constructor factory) used for nested validation/materialization.
|
|
398
|
-
* @param options Optional validation behavior (`message`, `
|
|
335
|
+
* @param options Optional validation behavior (`message`, `code`, `each`); collection traversal is automatic.
|
|
399
336
|
* @returns A field decorator that registers recursive nested DTO validation.
|
|
400
337
|
*/
|
|
401
338
|
export function ValidateNested(dto, options) {
|
|
@@ -410,7 +347,7 @@ export function ValidateNested(dto, options) {
|
|
|
410
347
|
* Validates that the decorated field has at least the given length.
|
|
411
348
|
*
|
|
412
349
|
* @param value Inclusive minimum string length.
|
|
413
|
-
* @param options Optional validation behavior (`message`, `
|
|
350
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
414
351
|
* @returns A field decorator that registers a minimum-length rule.
|
|
415
352
|
*/
|
|
416
353
|
export const MinLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -422,7 +359,7 @@ export const MinLength = createValidationOptionsWithConfigDecorator((value, opti
|
|
|
422
359
|
* Validates that the decorated field has at most the given length.
|
|
423
360
|
*
|
|
424
361
|
* @param value Inclusive maximum string length.
|
|
425
|
-
* @param options Optional validation behavior (`message`, `
|
|
362
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
426
363
|
* @returns A field decorator that registers a maximum-length rule.
|
|
427
364
|
*/
|
|
428
365
|
export const MaxLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -460,196 +397,196 @@ export function Matches(pattern, modifiersOrOptions, options) {
|
|
|
460
397
|
/**
|
|
461
398
|
* Validates that the decorated field contains only alphabetic characters.
|
|
462
399
|
*
|
|
463
|
-
* @param options Optional validation behavior (`message`, `
|
|
400
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
464
401
|
* @returns A field decorator that registers an alphabetic string rule.
|
|
465
402
|
*/
|
|
466
403
|
export const IsAlpha = options => createValidatorJsDecorator('alpha')(undefined, options);
|
|
467
404
|
/**
|
|
468
405
|
* Validates that the decorated field contains only alphanumeric characters.
|
|
469
406
|
*
|
|
470
|
-
* @param options Optional validation behavior (`message`, `
|
|
407
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
471
408
|
* @returns A field decorator that registers an alphanumeric string rule.
|
|
472
409
|
*/
|
|
473
410
|
export const IsAlphanumeric = options => createValidatorJsDecorator('alphanumeric')(undefined, options);
|
|
474
411
|
/**
|
|
475
412
|
* Validates that the decorated field contains only ASCII characters.
|
|
476
413
|
*
|
|
477
|
-
* @param options Optional validation behavior (`message`, `
|
|
414
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
478
415
|
* @returns A field decorator that registers an ASCII string rule.
|
|
479
416
|
*/
|
|
480
417
|
export const IsAscii = options => createValidatorJsDecorator('ascii')(undefined, options);
|
|
481
418
|
/**
|
|
482
419
|
* Validates that the decorated field is a Base64 string.
|
|
483
420
|
*
|
|
484
|
-
* @param options Optional validation behavior (`message`, `
|
|
421
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
485
422
|
* @returns A field decorator that registers a Base64 string rule.
|
|
486
423
|
*/
|
|
487
424
|
export const IsBase64 = options => createValidatorJsDecorator('base64')(undefined, options);
|
|
488
425
|
/**
|
|
489
426
|
* Validates that the decorated field is a boolean-like string.
|
|
490
427
|
*
|
|
491
|
-
* @param options Optional validation behavior (`message`, `
|
|
428
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
492
429
|
* @returns A field decorator that registers a boolean-string rule.
|
|
493
430
|
*/
|
|
494
431
|
export const IsBooleanString = options => createValidatorJsDecorator('booleanString')(undefined, options);
|
|
495
432
|
/**
|
|
496
433
|
* Validates that the decorated field is a data URI string.
|
|
497
434
|
*
|
|
498
|
-
* @param options Optional validation behavior (`message`, `
|
|
435
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
499
436
|
* @returns A field decorator that registers a data URI rule.
|
|
500
437
|
*/
|
|
501
438
|
export const IsDataURI = options => createValidatorJsDecorator('dataURI')(undefined, options);
|
|
502
439
|
/**
|
|
503
440
|
* Validates that the decorated field is a date string.
|
|
504
441
|
*
|
|
505
|
-
* @param options Optional validation behavior (`message`, `
|
|
442
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
506
443
|
* @returns A field decorator that registers a date-string rule.
|
|
507
444
|
*/
|
|
508
445
|
export const IsDateString = options => createValidatorJsDecorator('dateString')(undefined, options);
|
|
509
446
|
/**
|
|
510
447
|
* Validates that the decorated field is a decimal string.
|
|
511
448
|
*
|
|
512
|
-
* @param options Optional validation behavior (`message`, `
|
|
449
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
513
450
|
* @returns A field decorator that registers a decimal-string rule.
|
|
514
451
|
*/
|
|
515
452
|
export const IsDecimal = options => createValidatorJsDecorator('decimal')(undefined, options);
|
|
516
453
|
/**
|
|
517
454
|
* Validates that the decorated field is an email address.
|
|
518
455
|
*
|
|
519
|
-
* @param options Optional validation behavior (`message`, `
|
|
456
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
520
457
|
* @returns A field decorator that registers an email-address rule.
|
|
521
458
|
*/
|
|
522
459
|
export const IsEmail = options => createValidatorJsDecorator('email')(undefined, options);
|
|
523
460
|
/**
|
|
524
461
|
* Validates that the decorated field is a fully qualified domain name.
|
|
525
462
|
*
|
|
526
|
-
* @param options Optional validation behavior (`message`, `
|
|
463
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
527
464
|
* @returns A field decorator that registers an FQDN rule.
|
|
528
465
|
*/
|
|
529
466
|
export const IsFQDN = options => createValidatorJsDecorator('fqdn')(undefined, options);
|
|
530
467
|
/**
|
|
531
468
|
* Validates that the decorated field is a hexadecimal color string.
|
|
532
469
|
*
|
|
533
|
-
* @param options Optional validation behavior (`message`, `
|
|
470
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
534
471
|
* @returns A field decorator that registers a hex-color rule.
|
|
535
472
|
*/
|
|
536
473
|
export const IsHexColor = options => createValidatorJsDecorator('hexColor')(undefined, options);
|
|
537
474
|
/**
|
|
538
475
|
* Validates that the decorated field is a hexadecimal string.
|
|
539
476
|
*
|
|
540
|
-
* @param options Optional validation behavior (`message`, `
|
|
477
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
541
478
|
* @returns A field decorator that registers a hexadecimal string rule.
|
|
542
479
|
*/
|
|
543
480
|
export const IsHexadecimal = options => createValidatorJsDecorator('hexadecimal')(undefined, options);
|
|
544
481
|
/**
|
|
545
482
|
* Validates that the decorated field is a JSON string.
|
|
546
483
|
*
|
|
547
|
-
* @param options Optional validation behavior (`message`, `
|
|
484
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
548
485
|
* @returns A field decorator that registers a JSON-string rule.
|
|
549
486
|
*/
|
|
550
487
|
export const IsJSON = options => createValidatorJsDecorator('json')(undefined, options);
|
|
551
488
|
/**
|
|
552
489
|
* Validates that the decorated field is a JSON Web Token string.
|
|
553
490
|
*
|
|
554
|
-
* @param options Optional validation behavior (`message`, `
|
|
491
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
555
492
|
* @returns A field decorator that registers a JWT-string rule.
|
|
556
493
|
*/
|
|
557
494
|
export const IsJWT = options => createValidatorJsDecorator('jwt')(undefined, options);
|
|
558
495
|
/**
|
|
559
496
|
* Validates that the decorated field is a locale identifier.
|
|
560
497
|
*
|
|
561
|
-
* @param options Optional validation behavior (`message`, `
|
|
498
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
562
499
|
* @returns A field decorator that registers a locale-string rule.
|
|
563
500
|
*/
|
|
564
501
|
export const IsLocale = options => createValidatorJsDecorator('locale')(undefined, options);
|
|
565
502
|
/**
|
|
566
503
|
* Validates that the decorated field is lowercase.
|
|
567
504
|
*
|
|
568
|
-
* @param options Optional validation behavior (`message`, `
|
|
505
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
569
506
|
* @returns A field decorator that registers a lowercase-string rule.
|
|
570
507
|
*/
|
|
571
508
|
export const IsLowercase = options => createValidatorJsDecorator('lowercase')(undefined, options);
|
|
572
509
|
/**
|
|
573
510
|
* Validates that the decorated field is a magnet URI string.
|
|
574
511
|
*
|
|
575
|
-
* @param options Optional validation behavior (`message`, `
|
|
512
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
576
513
|
* @returns A field decorator that registers a magnet URI rule.
|
|
577
514
|
*/
|
|
578
515
|
export const IsMagnetURI = options => createValidatorJsDecorator('magnetURI')(undefined, options);
|
|
579
516
|
/**
|
|
580
517
|
* Validates that the decorated field is a MIME type string.
|
|
581
518
|
*
|
|
582
|
-
* @param options Optional validation behavior (`message`, `
|
|
519
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
583
520
|
* @returns A field decorator that registers a MIME type rule.
|
|
584
521
|
*/
|
|
585
522
|
export const IsMimeType = options => createValidatorJsDecorator('mimeType')(undefined, options);
|
|
586
523
|
/**
|
|
587
524
|
* Validates that the decorated field is a MongoDB object ID string.
|
|
588
525
|
*
|
|
589
|
-
* @param options Optional validation behavior (`message`, `
|
|
526
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
590
527
|
* @returns A field decorator that registers a MongoDB object ID rule.
|
|
591
528
|
*/
|
|
592
529
|
export const IsMongoId = options => createValidatorJsDecorator('mongoId')(undefined, options);
|
|
593
530
|
/**
|
|
594
531
|
* Validates that the decorated field is a numeric string.
|
|
595
532
|
*
|
|
596
|
-
* @param options Optional validation behavior (`message`, `
|
|
533
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
597
534
|
* @returns A field decorator that registers a numeric-string rule.
|
|
598
535
|
*/
|
|
599
536
|
export const IsNumberString = options => createValidatorJsDecorator('numberString')(undefined, options);
|
|
600
537
|
/**
|
|
601
538
|
* Validates that the decorated field is a network port string.
|
|
602
539
|
*
|
|
603
|
-
* @param options Optional validation behavior (`message`, `
|
|
540
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
604
541
|
* @returns A field decorator that registers a port-string rule.
|
|
605
542
|
*/
|
|
606
543
|
export const IsPort = options => createValidatorJsDecorator('port')(undefined, options);
|
|
607
544
|
/**
|
|
608
545
|
* Validates that the decorated field is an RFC 3339 date-time string.
|
|
609
546
|
*
|
|
610
|
-
* @param options Optional validation behavior (`message`, `
|
|
547
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
611
548
|
* @returns A field decorator that registers an RFC 3339 string rule.
|
|
612
549
|
*/
|
|
613
550
|
export const IsRFC3339 = options => createValidatorJsDecorator('rfc3339')(undefined, options);
|
|
614
551
|
/**
|
|
615
552
|
* Validates that the decorated field is a semantic version string.
|
|
616
553
|
*
|
|
617
|
-
* @param options Optional validation behavior (`message`, `
|
|
554
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
618
555
|
* @returns A field decorator that registers a semantic-version rule.
|
|
619
556
|
*/
|
|
620
557
|
export const IsSemVer = options => createValidatorJsDecorator('semVer')(undefined, options);
|
|
621
558
|
/**
|
|
622
559
|
* Validates that the decorated field is uppercase.
|
|
623
560
|
*
|
|
624
|
-
* @param options Optional validation behavior (`message`, `
|
|
561
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
625
562
|
* @returns A field decorator that registers an uppercase-string rule.
|
|
626
563
|
*/
|
|
627
564
|
export const IsUppercase = options => createValidatorJsDecorator('uppercase')(undefined, options);
|
|
628
565
|
/**
|
|
629
566
|
* Validates that the decorated field is an ISO 8601 date-time string.
|
|
630
567
|
*
|
|
631
|
-
* @param options Optional validation behavior (`message`, `
|
|
568
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
632
569
|
* @returns A field decorator that registers an ISO 8601 string rule.
|
|
633
570
|
*/
|
|
634
571
|
export const IsISO8601 = options => createValidatorJsDecorator('iso8601')(undefined, options);
|
|
635
572
|
/**
|
|
636
573
|
* Validates that the decorated field is a latitude value.
|
|
637
574
|
*
|
|
638
|
-
* @param options Optional validation behavior (`message`, `
|
|
575
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
639
576
|
* @returns A field decorator that registers a latitude rule.
|
|
640
577
|
*/
|
|
641
578
|
export const IsLatitude = options => createValidatorJsDecorator('latitude')(undefined, options);
|
|
642
579
|
/**
|
|
643
580
|
* Validates that the decorated field is a longitude value.
|
|
644
581
|
*
|
|
645
|
-
* @param options Optional validation behavior (`message`, `
|
|
582
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
646
583
|
* @returns A field decorator that registers a longitude rule.
|
|
647
584
|
*/
|
|
648
585
|
export const IsLongitude = options => createValidatorJsDecorator('longitude')(undefined, options);
|
|
649
586
|
/**
|
|
650
587
|
* Validates that the decorated field is a latitude/longitude coordinate string.
|
|
651
588
|
*
|
|
652
|
-
* @param options Optional validation behavior (`message`, `
|
|
589
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
653
590
|
* @returns A field decorator that registers a latitude/longitude rule.
|
|
654
591
|
*/
|
|
655
592
|
export const IsLatLong = options => createValidatorJsDecorator('latLong')(undefined, options);
|
|
@@ -662,7 +599,7 @@ export const IsLatLong = options => createValidatorJsDecorator('latLong')(undefi
|
|
|
662
599
|
* version only.
|
|
663
600
|
*
|
|
664
601
|
* @param version Optional IP version filter (`'4'`, `'6'`, or `'4_or_6'`).
|
|
665
|
-
* @param options Optional validation behavior (`message`, `
|
|
602
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
666
603
|
* @returns A field decorator that registers an IP-address rule.
|
|
667
604
|
*/
|
|
668
605
|
export function IsIP(version, options) {
|
|
@@ -758,7 +695,7 @@ export function IsCurrency(options) {
|
|
|
758
695
|
* Validates that the decorated array contains all required values.
|
|
759
696
|
*
|
|
760
697
|
* @param values Required values that must be present in the array.
|
|
761
|
-
* @param options Optional validation behavior (`message`, `
|
|
698
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
762
699
|
* @returns A field decorator that registers an array-contains rule.
|
|
763
700
|
*/
|
|
764
701
|
export const ArrayContains = createArrayValidationDecorator((values, options) => ({
|
|
@@ -770,7 +707,7 @@ export const ArrayContains = createArrayValidationDecorator((values, options) =>
|
|
|
770
707
|
* Validates that the decorated array excludes all forbidden values.
|
|
771
708
|
*
|
|
772
709
|
* @param values Forbidden values that must not be present in the array.
|
|
773
|
-
* @param options Optional validation behavior (`message`, `
|
|
710
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
774
711
|
* @returns A field decorator that registers an array-exclusion rule.
|
|
775
712
|
*/
|
|
776
713
|
export const ArrayNotContains = createArrayValidationDecorator((values, options) => ({
|
|
@@ -781,7 +718,7 @@ export const ArrayNotContains = createArrayValidationDecorator((values, options)
|
|
|
781
718
|
/**
|
|
782
719
|
* Validates that the decorated array is not empty.
|
|
783
720
|
*
|
|
784
|
-
* @param options Optional validation behavior (`message`, `
|
|
721
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
785
722
|
* @returns A field decorator that registers a non-empty-array rule.
|
|
786
723
|
*/
|
|
787
724
|
export const ArrayNotEmpty = createFlagValidationDecorator(options => ({
|
|
@@ -792,7 +729,7 @@ export const ArrayNotEmpty = createFlagValidationDecorator(options => ({
|
|
|
792
729
|
* Validates that the decorated array has at least the given size.
|
|
793
730
|
*
|
|
794
731
|
* @param value Inclusive minimum array length.
|
|
795
|
-
* @param options Optional validation behavior (`message`, `
|
|
732
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
796
733
|
* @returns A field decorator that registers a minimum-array-size rule.
|
|
797
734
|
*/
|
|
798
735
|
export const ArrayMinSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
@@ -804,7 +741,7 @@ export const ArrayMinSize = createValidationOptionsWithConfigDecorator((value, o
|
|
|
804
741
|
* Validates that the decorated array has at most the given size.
|
|
805
742
|
*
|
|
806
743
|
* @param value Inclusive maximum array length.
|
|
807
|
-
* @param options Optional validation behavior (`message`, `
|
|
744
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
808
745
|
* @returns A field decorator that registers a maximum-array-size rule.
|
|
809
746
|
*/
|
|
810
747
|
export const ArrayMaxSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|