@fluojs/validation 1.0.0-beta.1 → 1.0.0-beta.3
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 +75 -57
- package/README.md +44 -4
- package/dist/decorators.d.ts +284 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +298 -4
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/standard-schema.d.ts +18 -0
- package/dist/standard-schema.d.ts.map +1 -1
- package/dist/standard-schema.js +21 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +4 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +15 -2
- 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,EACL,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EAErC,KAAK,0BAA0B,EAChC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAgE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG/H,KAAK,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAClF,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AAElH,KAAK,kBAAkB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;
|
|
1
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AA0B,GAAG,gBAAgB,CAUlH"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ensureMetadataSymbol } from '@fluojs/core/internal';
|
|
2
2
|
import { createClassValidatorFromStandardSchema, isStandardSchemaLike } from './standard-schema.js';
|
|
3
3
|
const standardDtoValidationMetadataKey = Symbol.for('fluo.standard.dto-validation');
|
|
4
4
|
const standardClassValidationMetadataKey = Symbol.for('fluo.standard.class-validation');
|
|
5
|
+
ensureMetadataSymbol();
|
|
5
6
|
function getStandardMetadataBag(metadata) {
|
|
6
7
|
if (metadata === null || metadata === undefined) {
|
|
7
8
|
throw new Error('Decorator metadata is not available. Ensure your environment supports TC39 decorator metadata (Stage 3).');
|
|
8
9
|
}
|
|
9
|
-
void metadataSymbol;
|
|
10
10
|
return metadata;
|
|
11
11
|
}
|
|
12
12
|
function getStandardDtoValidationMap(metadata) {
|
|
@@ -125,62 +125,105 @@ export const ValidateIf = (validateIf, options) => createValidationDecorator(()
|
|
|
125
125
|
validateIf,
|
|
126
126
|
...options
|
|
127
127
|
}));
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Provides the is defined value.
|
|
131
|
+
*/
|
|
128
132
|
export const IsDefined = createFlagValidationDecorator(options => ({
|
|
129
133
|
kind: 'defined',
|
|
130
134
|
...options
|
|
131
135
|
}));
|
|
136
|
+
/**
|
|
137
|
+
* Provides the is optional value.
|
|
138
|
+
*/
|
|
132
139
|
export const IsOptional = createFlagValidationDecorator(options => ({
|
|
133
140
|
kind: 'optional',
|
|
134
141
|
...options
|
|
135
142
|
}));
|
|
143
|
+
/**
|
|
144
|
+
* Provides the equals value.
|
|
145
|
+
*/
|
|
136
146
|
export const Equals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
137
147
|
kind: 'equals',
|
|
138
148
|
value,
|
|
139
149
|
...options
|
|
140
150
|
}));
|
|
151
|
+
/**
|
|
152
|
+
* Provides the not equals value.
|
|
153
|
+
*/
|
|
141
154
|
export const NotEquals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
142
155
|
kind: 'notEquals',
|
|
143
156
|
value,
|
|
144
157
|
...options
|
|
145
158
|
}));
|
|
159
|
+
/**
|
|
160
|
+
* Provides the is empty value.
|
|
161
|
+
*/
|
|
146
162
|
export const IsEmpty = createFlagValidationDecorator(options => ({
|
|
147
163
|
kind: 'empty',
|
|
148
164
|
...options
|
|
149
165
|
}));
|
|
166
|
+
/**
|
|
167
|
+
* Provides the is not empty value.
|
|
168
|
+
*/
|
|
150
169
|
export const IsNotEmpty = createFlagValidationDecorator(options => ({
|
|
151
170
|
kind: 'notEmpty',
|
|
152
171
|
...options
|
|
153
172
|
}));
|
|
173
|
+
/**
|
|
174
|
+
* Provides the is in value.
|
|
175
|
+
*/
|
|
154
176
|
export const IsIn = createArrayValidationDecorator((values, options) => ({
|
|
155
177
|
kind: 'in',
|
|
156
178
|
values,
|
|
157
179
|
...options
|
|
158
180
|
}));
|
|
181
|
+
/**
|
|
182
|
+
* Provides the is not in value.
|
|
183
|
+
*/
|
|
159
184
|
export const IsNotIn = createArrayValidationDecorator((values, options) => ({
|
|
160
185
|
kind: 'notIn',
|
|
161
186
|
values,
|
|
162
187
|
...options
|
|
163
188
|
}));
|
|
189
|
+
/**
|
|
190
|
+
* Provides the is date value.
|
|
191
|
+
*/
|
|
164
192
|
export const IsDate = createFlagValidationDecorator(options => ({
|
|
165
193
|
kind: 'date',
|
|
166
194
|
...options
|
|
167
195
|
}));
|
|
196
|
+
/**
|
|
197
|
+
* Provides the is array value.
|
|
198
|
+
*/
|
|
168
199
|
export const IsArray = createFlagValidationDecorator(options => ({
|
|
169
200
|
kind: 'array',
|
|
170
201
|
...options
|
|
171
202
|
}));
|
|
203
|
+
/**
|
|
204
|
+
* Provides the is object value.
|
|
205
|
+
*/
|
|
172
206
|
export const IsObject = createFlagValidationDecorator(options => ({
|
|
173
207
|
kind: 'object',
|
|
174
208
|
...options
|
|
175
209
|
}));
|
|
210
|
+
/**
|
|
211
|
+
* Provides the is int value.
|
|
212
|
+
*/
|
|
176
213
|
export const IsInt = createFlagValidationDecorator(options => ({
|
|
177
214
|
kind: 'int',
|
|
178
215
|
...options
|
|
179
216
|
}));
|
|
217
|
+
/**
|
|
218
|
+
* Provides the is positive value.
|
|
219
|
+
*/
|
|
180
220
|
export const IsPositive = createFlagValidationDecorator(options => ({
|
|
181
221
|
kind: 'positive',
|
|
182
222
|
...options
|
|
183
223
|
}));
|
|
224
|
+
/**
|
|
225
|
+
* Provides the is negative value.
|
|
226
|
+
*/
|
|
184
227
|
export const IsNegative = createFlagValidationDecorator(options => ({
|
|
185
228
|
kind: 'negative',
|
|
186
229
|
...options
|
|
@@ -201,36 +244,58 @@ export function IsEnum(values, options) {
|
|
|
201
244
|
...options
|
|
202
245
|
}));
|
|
203
246
|
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Provides the is divisible by value.
|
|
250
|
+
*/
|
|
204
251
|
export const IsDivisibleBy = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
205
252
|
kind: 'divisibleBy',
|
|
206
253
|
value,
|
|
207
254
|
...options
|
|
208
255
|
}));
|
|
256
|
+
/**
|
|
257
|
+
* Provides the min value.
|
|
258
|
+
*/
|
|
209
259
|
export const Min = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
210
260
|
kind: 'min',
|
|
211
261
|
value,
|
|
212
262
|
...options
|
|
213
263
|
}));
|
|
264
|
+
/**
|
|
265
|
+
* Provides the max value.
|
|
266
|
+
*/
|
|
214
267
|
export const Max = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
215
268
|
kind: 'max',
|
|
216
269
|
value,
|
|
217
270
|
...options
|
|
218
271
|
}));
|
|
272
|
+
/**
|
|
273
|
+
* Provides the min date value.
|
|
274
|
+
*/
|
|
219
275
|
export const MinDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
220
276
|
kind: 'minDate',
|
|
221
277
|
value,
|
|
222
278
|
...options
|
|
223
279
|
}));
|
|
280
|
+
/**
|
|
281
|
+
* Provides the max date value.
|
|
282
|
+
*/
|
|
224
283
|
export const MaxDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
225
284
|
kind: 'maxDate',
|
|
226
285
|
value,
|
|
227
286
|
...options
|
|
228
287
|
}));
|
|
288
|
+
/**
|
|
289
|
+
* Provides the contains value.
|
|
290
|
+
*/
|
|
229
291
|
export const Contains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
230
292
|
kind: 'contains',
|
|
231
293
|
value,
|
|
232
294
|
...options
|
|
233
295
|
}));
|
|
296
|
+
/**
|
|
297
|
+
* Provides the not contains value.
|
|
298
|
+
*/
|
|
234
299
|
export const NotContains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
235
300
|
kind: 'notContains',
|
|
236
301
|
value,
|
|
@@ -268,11 +333,18 @@ export function ValidateNested(dto, options) {
|
|
|
268
333
|
...options
|
|
269
334
|
}));
|
|
270
335
|
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Provides the min length value.
|
|
339
|
+
*/
|
|
271
340
|
export const MinLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
272
341
|
kind: 'minLength',
|
|
273
342
|
value,
|
|
274
343
|
...options
|
|
275
344
|
}));
|
|
345
|
+
/**
|
|
346
|
+
* Provides the max length value.
|
|
347
|
+
*/
|
|
276
348
|
export const MaxLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
277
349
|
kind: 'maxLength',
|
|
278
350
|
value,
|
|
@@ -304,84 +376,306 @@ export function Matches(pattern, modifiersOrOptions, options) {
|
|
|
304
376
|
...resolvedOptions
|
|
305
377
|
}));
|
|
306
378
|
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Provides the is alpha value.
|
|
382
|
+
*
|
|
383
|
+
* @param options The options.
|
|
384
|
+
*/
|
|
307
385
|
export const IsAlpha = options => createValidatorJsDecorator('alpha')(undefined, options);
|
|
386
|
+
/**
|
|
387
|
+
* Provides the is alphanumeric value.
|
|
388
|
+
*
|
|
389
|
+
* @param options The options.
|
|
390
|
+
*/
|
|
308
391
|
export const IsAlphanumeric = options => createValidatorJsDecorator('alphanumeric')(undefined, options);
|
|
392
|
+
/**
|
|
393
|
+
* Provides the is ascii value.
|
|
394
|
+
*
|
|
395
|
+
* @param options The options.
|
|
396
|
+
*/
|
|
309
397
|
export const IsAscii = options => createValidatorJsDecorator('ascii')(undefined, options);
|
|
398
|
+
/**
|
|
399
|
+
* Provides the is base64 value.
|
|
400
|
+
*
|
|
401
|
+
* @param options The options.
|
|
402
|
+
*/
|
|
310
403
|
export const IsBase64 = options => createValidatorJsDecorator('base64')(undefined, options);
|
|
404
|
+
/**
|
|
405
|
+
* Provides the is boolean string value.
|
|
406
|
+
*
|
|
407
|
+
* @param options The options.
|
|
408
|
+
*/
|
|
311
409
|
export const IsBooleanString = options => createValidatorJsDecorator('booleanString')(undefined, options);
|
|
410
|
+
/**
|
|
411
|
+
* Provides the is data uri value.
|
|
412
|
+
*
|
|
413
|
+
* @param options The options.
|
|
414
|
+
*/
|
|
312
415
|
export const IsDataURI = options => createValidatorJsDecorator('dataURI')(undefined, options);
|
|
416
|
+
/**
|
|
417
|
+
* Provides the is date string value.
|
|
418
|
+
*
|
|
419
|
+
* @param options The options.
|
|
420
|
+
*/
|
|
313
421
|
export const IsDateString = options => createValidatorJsDecorator('dateString')(undefined, options);
|
|
422
|
+
/**
|
|
423
|
+
* Provides the is decimal value.
|
|
424
|
+
*
|
|
425
|
+
* @param options The options.
|
|
426
|
+
*/
|
|
314
427
|
export const IsDecimal = options => createValidatorJsDecorator('decimal')(undefined, options);
|
|
428
|
+
/**
|
|
429
|
+
* Provides the is email value.
|
|
430
|
+
*
|
|
431
|
+
* @param options The options.
|
|
432
|
+
*/
|
|
315
433
|
export const IsEmail = options => createValidatorJsDecorator('email')(undefined, options);
|
|
434
|
+
/**
|
|
435
|
+
* Provides the is fqdn value.
|
|
436
|
+
*
|
|
437
|
+
* @param options The options.
|
|
438
|
+
*/
|
|
316
439
|
export const IsFQDN = options => createValidatorJsDecorator('fqdn')(undefined, options);
|
|
440
|
+
/**
|
|
441
|
+
* Provides the is hex color value.
|
|
442
|
+
*
|
|
443
|
+
* @param options The options.
|
|
444
|
+
*/
|
|
317
445
|
export const IsHexColor = options => createValidatorJsDecorator('hexColor')(undefined, options);
|
|
446
|
+
/**
|
|
447
|
+
* Provides the is hexadecimal value.
|
|
448
|
+
*
|
|
449
|
+
* @param options The options.
|
|
450
|
+
*/
|
|
318
451
|
export const IsHexadecimal = options => createValidatorJsDecorator('hexadecimal')(undefined, options);
|
|
452
|
+
/**
|
|
453
|
+
* Provides the is json value.
|
|
454
|
+
*
|
|
455
|
+
* @param options The options.
|
|
456
|
+
*/
|
|
319
457
|
export const IsJSON = options => createValidatorJsDecorator('json')(undefined, options);
|
|
458
|
+
/**
|
|
459
|
+
* Provides the is jwt value.
|
|
460
|
+
*
|
|
461
|
+
* @param options The options.
|
|
462
|
+
*/
|
|
320
463
|
export const IsJWT = options => createValidatorJsDecorator('jwt')(undefined, options);
|
|
464
|
+
/**
|
|
465
|
+
* Provides the is locale value.
|
|
466
|
+
*
|
|
467
|
+
* @param options The options.
|
|
468
|
+
*/
|
|
321
469
|
export const IsLocale = options => createValidatorJsDecorator('locale')(undefined, options);
|
|
470
|
+
/**
|
|
471
|
+
* Provides the is lowercase value.
|
|
472
|
+
*
|
|
473
|
+
* @param options The options.
|
|
474
|
+
*/
|
|
322
475
|
export const IsLowercase = options => createValidatorJsDecorator('lowercase')(undefined, options);
|
|
476
|
+
/**
|
|
477
|
+
* Provides the is magnet uri value.
|
|
478
|
+
*
|
|
479
|
+
* @param options The options.
|
|
480
|
+
*/
|
|
323
481
|
export const IsMagnetURI = options => createValidatorJsDecorator('magnetURI')(undefined, options);
|
|
482
|
+
/**
|
|
483
|
+
* Provides the is mime type value.
|
|
484
|
+
*
|
|
485
|
+
* @param options The options.
|
|
486
|
+
*/
|
|
324
487
|
export const IsMimeType = options => createValidatorJsDecorator('mimeType')(undefined, options);
|
|
488
|
+
/**
|
|
489
|
+
* Provides the is mongo id value.
|
|
490
|
+
*
|
|
491
|
+
* @param options The options.
|
|
492
|
+
*/
|
|
325
493
|
export const IsMongoId = options => createValidatorJsDecorator('mongoId')(undefined, options);
|
|
494
|
+
/**
|
|
495
|
+
* Provides the is number string value.
|
|
496
|
+
*
|
|
497
|
+
* @param options The options.
|
|
498
|
+
*/
|
|
326
499
|
export const IsNumberString = options => createValidatorJsDecorator('numberString')(undefined, options);
|
|
500
|
+
/**
|
|
501
|
+
* Provides the is port value.
|
|
502
|
+
*
|
|
503
|
+
* @param options The options.
|
|
504
|
+
*/
|
|
327
505
|
export const IsPort = options => createValidatorJsDecorator('port')(undefined, options);
|
|
506
|
+
/**
|
|
507
|
+
* Provides the is rfc3339 value.
|
|
508
|
+
*
|
|
509
|
+
* @param options The options.
|
|
510
|
+
*/
|
|
328
511
|
export const IsRFC3339 = options => createValidatorJsDecorator('rfc3339')(undefined, options);
|
|
512
|
+
/**
|
|
513
|
+
* Provides the is sem ver value.
|
|
514
|
+
*
|
|
515
|
+
* @param options The options.
|
|
516
|
+
*/
|
|
329
517
|
export const IsSemVer = options => createValidatorJsDecorator('semVer')(undefined, options);
|
|
518
|
+
/**
|
|
519
|
+
* Provides the is uppercase value.
|
|
520
|
+
*
|
|
521
|
+
* @param options The options.
|
|
522
|
+
*/
|
|
330
523
|
export const IsUppercase = options => createValidatorJsDecorator('uppercase')(undefined, options);
|
|
524
|
+
/**
|
|
525
|
+
* Provides the is iso8601 value.
|
|
526
|
+
*
|
|
527
|
+
* @param options The options.
|
|
528
|
+
*/
|
|
331
529
|
export const IsISO8601 = options => createValidatorJsDecorator('iso8601')(undefined, options);
|
|
530
|
+
/**
|
|
531
|
+
* Provides the is latitude value.
|
|
532
|
+
*
|
|
533
|
+
* @param options The options.
|
|
534
|
+
*/
|
|
332
535
|
export const IsLatitude = options => createValidatorJsDecorator('latitude')(undefined, options);
|
|
536
|
+
/**
|
|
537
|
+
* Provides the is longitude value.
|
|
538
|
+
*
|
|
539
|
+
* @param options The options.
|
|
540
|
+
*/
|
|
333
541
|
export const IsLongitude = options => createValidatorJsDecorator('longitude')(undefined, options);
|
|
542
|
+
/**
|
|
543
|
+
* Provides the is lat long value.
|
|
544
|
+
*
|
|
545
|
+
* @param options The options.
|
|
546
|
+
*/
|
|
334
547
|
export const IsLatLong = options => createValidatorJsDecorator('latLong')(undefined, options);
|
|
335
548
|
|
|
336
|
-
/**
|
|
549
|
+
/**
|
|
550
|
+
* Validates that a value is an IPv4/IPv6 address.
|
|
551
|
+
*
|
|
552
|
+
* @param version The version.
|
|
553
|
+
* @param options The options.
|
|
554
|
+
* @returns The is ip result.
|
|
555
|
+
*/
|
|
337
556
|
export function IsIP(version, options) {
|
|
338
557
|
return createValidatorJsDecorator('ip')(version ? [version] : undefined, options);
|
|
339
558
|
}
|
|
340
559
|
|
|
341
|
-
/**
|
|
560
|
+
/**
|
|
561
|
+
* Validates that a value is an ISBN string.
|
|
562
|
+
*
|
|
563
|
+
* @param version The version.
|
|
564
|
+
* @param options The options.
|
|
565
|
+
* @returns The is isbn result.
|
|
566
|
+
*/
|
|
342
567
|
export function IsISBN(version, options) {
|
|
343
568
|
return createValidatorJsDecorator('isbn')(version ? [String(version)] : undefined, options);
|
|
344
569
|
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Is issn.
|
|
573
|
+
*
|
|
574
|
+
* @param options The options.
|
|
575
|
+
* @returns The is issn result.
|
|
576
|
+
*/
|
|
345
577
|
export function IsISSN(options) {
|
|
346
578
|
return createValidatorJsDecorator('issn')(undefined, options);
|
|
347
579
|
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Is mobile phone.
|
|
583
|
+
*
|
|
584
|
+
* @param locale The locale.
|
|
585
|
+
* @param options The options.
|
|
586
|
+
* @returns The is mobile phone result.
|
|
587
|
+
*/
|
|
348
588
|
export function IsMobilePhone(locale, options) {
|
|
349
589
|
return createValidatorJsDecorator('mobilePhone')(locale ? [locale] : undefined, options);
|
|
350
590
|
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Is postal code.
|
|
594
|
+
*
|
|
595
|
+
* @param locale The locale.
|
|
596
|
+
* @param options The options.
|
|
597
|
+
* @returns The is postal code result.
|
|
598
|
+
*/
|
|
351
599
|
export function IsPostalCode(locale, options) {
|
|
352
600
|
return createValidatorJsDecorator('postalCode')(locale ? [locale] : undefined, options);
|
|
353
601
|
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Is rgb color.
|
|
605
|
+
*
|
|
606
|
+
* @param includePercentValues The include percent values.
|
|
607
|
+
* @param options The options.
|
|
608
|
+
* @returns The is rgb color result.
|
|
609
|
+
*/
|
|
354
610
|
export function IsRgbColor(includePercentValues, options) {
|
|
355
611
|
return createValidatorJsDecorator('rgbColor')(includePercentValues === undefined ? undefined : [includePercentValues], options);
|
|
356
612
|
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Is url.
|
|
616
|
+
*
|
|
617
|
+
* @param options The options.
|
|
618
|
+
* @returns The is url result.
|
|
619
|
+
*/
|
|
357
620
|
export function IsUrl(options) {
|
|
358
621
|
return createValidatorJsDecorator('url')(undefined, options);
|
|
359
622
|
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Is uuid.
|
|
626
|
+
*
|
|
627
|
+
* @param version The version.
|
|
628
|
+
* @param options The options.
|
|
629
|
+
* @returns The is uuid result.
|
|
630
|
+
*/
|
|
360
631
|
export function IsUUID(version, options) {
|
|
361
632
|
return createValidatorJsDecorator('uuid')(version ? [version] : undefined, options);
|
|
362
633
|
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Is currency.
|
|
637
|
+
*
|
|
638
|
+
* @param options The options.
|
|
639
|
+
* @returns The is currency result.
|
|
640
|
+
*/
|
|
363
641
|
export function IsCurrency(options) {
|
|
364
642
|
return createValidatorJsDecorator('currency')(undefined, options);
|
|
365
643
|
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Provides the array contains value.
|
|
647
|
+
*/
|
|
366
648
|
export const ArrayContains = createArrayValidationDecorator((values, options) => ({
|
|
367
649
|
kind: 'arrayContains',
|
|
368
650
|
values,
|
|
369
651
|
...options
|
|
370
652
|
}));
|
|
653
|
+
/**
|
|
654
|
+
* Provides the array not contains value.
|
|
655
|
+
*/
|
|
371
656
|
export const ArrayNotContains = createArrayValidationDecorator((values, options) => ({
|
|
372
657
|
kind: 'arrayNotContains',
|
|
373
658
|
values,
|
|
374
659
|
...options
|
|
375
660
|
}));
|
|
661
|
+
/**
|
|
662
|
+
* Provides the array not empty value.
|
|
663
|
+
*/
|
|
376
664
|
export const ArrayNotEmpty = createFlagValidationDecorator(options => ({
|
|
377
665
|
kind: 'arrayNotEmpty',
|
|
378
666
|
...options
|
|
379
667
|
}));
|
|
668
|
+
/**
|
|
669
|
+
* Provides the array min size value.
|
|
670
|
+
*/
|
|
380
671
|
export const ArrayMinSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
381
672
|
kind: 'arrayMinSize',
|
|
382
673
|
value,
|
|
383
674
|
...options
|
|
384
675
|
}));
|
|
676
|
+
/**
|
|
677
|
+
* Provides the array max size value.
|
|
678
|
+
*/
|
|
385
679
|
export const ArrayMaxSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
386
680
|
kind: 'arrayMaxSize',
|
|
387
681
|
value,
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ValidationIssue } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the dto validation error.
|
|
4
|
+
*/
|
|
2
5
|
export declare class DtoValidationError extends Error {
|
|
3
6
|
readonly issues: readonly ValidationIssue[];
|
|
4
7
|
constructor(message: string, issues: readonly ValidationIssue[]);
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE;gBAD3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,eAAe,EAAE;CAM9C"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE;gBAD3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,eAAe,EAAE;CAM9C"}
|
package/dist/errors.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import type { CustomClassValidator } from '@fluojs/core/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Standard Schema v1-compatible validator accepted by `ValidateClass`.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Input Input DTO shape consumed by the schema validator.
|
|
7
|
+
* @typeParam Output Output DTO shape produced by the schema validator.
|
|
8
|
+
*/
|
|
3
9
|
export type StandardSchemaV1Like<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
|
|
10
|
+
/**
|
|
11
|
+
* Detect whether a value implements the Standard Schema v1 contract.
|
|
12
|
+
*
|
|
13
|
+
* @param value Candidate schema value supplied to validation decorators.
|
|
14
|
+
* @returns `true` when the candidate exposes a Standard Schema v1 validator.
|
|
15
|
+
*/
|
|
4
16
|
export declare function isStandardSchemaLike(value: unknown): value is StandardSchemaV1Like;
|
|
17
|
+
/**
|
|
18
|
+
* Adapt a Standard Schema validator to fluo class-level validation.
|
|
19
|
+
*
|
|
20
|
+
* @param schema Standard Schema-compatible validator definition.
|
|
21
|
+
* @returns A class validator that reports normalized validation issues.
|
|
22
|
+
*/
|
|
5
23
|
export declare function createClassValidatorFromStandardSchema(schema: StandardSchemaV1Like): CustomClassValidator;
|
|
6
24
|
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AA0CpG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAkBlF;AA4CD,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAgBzG"}
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AA0CpG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAkBlF;AA4CD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAgBzG"}
|
package/dist/standard-schema.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema v1-compatible validator accepted by `ValidateClass`.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam Input Input DTO shape consumed by the schema validator.
|
|
5
|
+
* @typeParam Output Output DTO shape produced by the schema validator.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
function toFieldPath(path) {
|
|
2
9
|
if (!path || path.length === 0) {
|
|
3
10
|
return undefined;
|
|
@@ -21,6 +28,13 @@ function normalizeCode(code, fallback) {
|
|
|
21
28
|
}
|
|
22
29
|
return code.replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '').toUpperCase() || fallback;
|
|
23
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Detect whether a value implements the Standard Schema v1 contract.
|
|
34
|
+
*
|
|
35
|
+
* @param value Candidate schema value supplied to validation decorators.
|
|
36
|
+
* @returns `true` when the candidate exposes a Standard Schema v1 validator.
|
|
37
|
+
*/
|
|
24
38
|
export function isStandardSchemaLike(value) {
|
|
25
39
|
if (typeof value !== 'object' && typeof value !== 'function' || value === null) {
|
|
26
40
|
return false;
|
|
@@ -58,6 +72,13 @@ function toStandardValidationIssue(issue) {
|
|
|
58
72
|
function isStandardSchemaFailureResult(result) {
|
|
59
73
|
return typeof result === 'object' && result !== null && 'issues' in result;
|
|
60
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Adapt a Standard Schema validator to fluo class-level validation.
|
|
78
|
+
*
|
|
79
|
+
* @param schema Standard Schema-compatible validator definition.
|
|
80
|
+
* @returns A class validator that reports normalized validation issues.
|
|
81
|
+
*/
|
|
61
82
|
export function createClassValidatorFromStandardSchema(schema) {
|
|
62
83
|
return async value => {
|
|
63
84
|
const result = await schema['~standard'].validate(value);
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClE,oEAAoE;IACpE,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CACzE"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClE,oEAAoE;IACpE,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CACzE"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Constructor } from '@fluojs/core';
|
|
2
2
|
import type { Validator } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the default validator.
|
|
5
|
+
*/
|
|
3
6
|
export declare class DefaultValidator implements Validator {
|
|
4
7
|
validate(value: unknown, target: Constructor): Promise<void>;
|
|
5
8
|
materialize<T>(value: unknown, target: Constructor<T>): Promise<T>;
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,cAAc,CAAC;AAatB,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAgxB7D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5D,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAczE"}
|