koatty_validation 1.0.10 → 1.2.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/dist/index.js CHANGED
@@ -1,20 +1,1385 @@
1
- "use strict";
2
- /**
3
- * @ author: richen
4
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
5
- * @ license: MIT
6
- * @ version: 2020-03-20 11:31:09
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.plainToClass = exports.convertDtoParamsType = exports.convertParamsType = exports.checkParamsType = void 0;
10
- const tslib_1 = require("tslib");
11
- // export for manual verification
12
- (0, tslib_1.__exportStar)(require("./rule"), exports);
13
- (0, tslib_1.__exportStar)(require("./decorator"), exports);
14
- var util_1 = require("./util");
15
- Object.defineProperty(exports, "checkParamsType", { enumerable: true, get: function () { return util_1.checkParamsType; } });
16
- Object.defineProperty(exports, "convertParamsType", { enumerable: true, get: function () { return util_1.convertParamsType; } });
17
- Object.defineProperty(exports, "convertDtoParamsType", { enumerable: true, get: function () { return util_1.convertDtoParamsType; } });
18
- Object.defineProperty(exports, "plainToClass", { enumerable: true, get: function () { return util_1.plainToClass; } });
19
- // export decorators from class-validator
20
- //# sourceMappingURL=index.js.map
1
+ /*!
2
+ * @Author: richen
3
+ * @Date: 2022-02-25 09:58:02
4
+ * @License: BSD (3-Clause)
5
+ * @Copyright (c) - <richenlin(at)gmail.com>
6
+ * @HomePage: https://koatty.org/
7
+ */
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var helper = require('koatty_lib');
13
+ require('reflect-metadata');
14
+ var koatty_container = require('koatty_container');
15
+ var classValidator = require('class-validator');
16
+
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n["default"] = e;
32
+ return Object.freeze(n);
33
+ }
34
+
35
+ var helper__namespace = /*#__PURE__*/_interopNamespace(helper);
36
+
37
+ /**
38
+ * @ author: richen
39
+ * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
40
+ * @ license: MIT
41
+ * @ version: 2020-03-20 11:34:38
42
+ */
43
+ /**
44
+ * Set property as included in the process of transformation.
45
+ *
46
+ * @export
47
+ * @param {Object} object
48
+ * @param {(string | symbol)} propertyName
49
+ */
50
+ function setExpose(object, propertyName) {
51
+ const types = Reflect.getMetadata("design:type", object, propertyName);
52
+ if (types) {
53
+ const originMap = koatty_container.getOriginMetadata(PARAM_TYPE_KEY, object);
54
+ originMap.set(propertyName, types.name);
55
+ }
56
+ }
57
+ /**
58
+ *
59
+ *
60
+ * @export
61
+ * @param {*} clazz
62
+ * @param {*} data
63
+ * @param {boolean} [convert=false]
64
+ * @returns
65
+ */
66
+ function plainToClass(clazz, data, convert = false) {
67
+ if (helper__namespace.isClass(clazz)) {
68
+ let cls;
69
+ if (!helper__namespace.isObject(data)) {
70
+ data = {};
71
+ }
72
+ if (data instanceof clazz) {
73
+ cls = data;
74
+ }
75
+ else {
76
+ cls = Reflect.construct(clazz, []);
77
+ }
78
+ if (convert) {
79
+ return convertDtoParamsType(clazz, cls, data);
80
+ }
81
+ return Object.assign(cls, data);
82
+ }
83
+ return data;
84
+ }
85
+ /**
86
+ * convertDtoParamsType
87
+ *
88
+ * @param {*} clazz
89
+ * @param {*} cls
90
+ * @param {*} data
91
+ * @returns {*}
92
+ */
93
+ function convertDtoParamsType(clazz, cls, data) {
94
+ if (Object.prototype.hasOwnProperty.call(cls, "_typeDef")) {
95
+ for (const key in cls) {
96
+ if (Object.prototype.hasOwnProperty.call(data, key)
97
+ && Object.prototype.hasOwnProperty.call(cls._typeDef, key)) {
98
+ data[key] = convertParamsType(data[key], cls._typeDef[key]);
99
+ }
100
+ }
101
+ }
102
+ else {
103
+ const originMap = koatty_container.getOriginMetadata(PARAM_TYPE_KEY, clazz);
104
+ for (const [key, type] of originMap) {
105
+ if (key && Object.prototype.hasOwnProperty.call(data, key)) {
106
+ cls[key] = convertParamsType(data[key], type);
107
+ }
108
+ }
109
+ }
110
+ return cls;
111
+ }
112
+ /**
113
+ * 绑定参数类型转换
114
+ *
115
+ * @param {*} param
116
+ * @param {string} type
117
+ * @returns {*}
118
+ */
119
+ function convertParamsType(param, type) {
120
+ try {
121
+ switch (type) {
122
+ case "Number":
123
+ case "number":
124
+ if (helper__namespace.isNaN(param)) {
125
+ return NaN;
126
+ }
127
+ if (helper__namespace.isNumber(param)) {
128
+ return param;
129
+ }
130
+ if (helper__namespace.isNumberString(param)) {
131
+ return helper__namespace.toNumber(param);
132
+ }
133
+ return NaN;
134
+ case "Boolean":
135
+ case "boolean":
136
+ return !!param;
137
+ case "Array":
138
+ case "array":
139
+ case "Tuple":
140
+ case "tuple":
141
+ if (helper__namespace.isArray(param)) {
142
+ return param;
143
+ }
144
+ return helper__namespace.toArray(param);
145
+ case "String":
146
+ case "string":
147
+ if (helper__namespace.isString(param)) {
148
+ return param;
149
+ }
150
+ return helper__namespace.toString(param);
151
+ case "Null":
152
+ case "null":
153
+ return null;
154
+ case "Undefined":
155
+ case "undefined":
156
+ return undefined;
157
+ case "Bigint":
158
+ case "bigint":
159
+ if (typeof param === 'bigint') {
160
+ return param;
161
+ }
162
+ return BigInt(param);
163
+ // case "object":
164
+ // case "enum":
165
+ default: //any
166
+ return param;
167
+ }
168
+ }
169
+ catch (err) {
170
+ return param;
171
+ }
172
+ }
173
+ /**
174
+ * Check the base types.
175
+ *
176
+ * @param {*} value
177
+ * @param {string} type
178
+ * @returns {*}
179
+ */
180
+ function checkParamsType(value, type) {
181
+ switch (type) {
182
+ case "Number":
183
+ case "number":
184
+ if (!helper__namespace.isNumber(value) || helper__namespace.isNaN(value)) {
185
+ return false;
186
+ }
187
+ return true;
188
+ case "Boolean":
189
+ case "boolean":
190
+ if (!helper__namespace.isBoolean(value)) {
191
+ return false;
192
+ }
193
+ return true;
194
+ case "Array":
195
+ case "array":
196
+ case "Tuple":
197
+ case "tuple":
198
+ if (!helper__namespace.isArray(value)) {
199
+ return false;
200
+ }
201
+ return true;
202
+ case "String":
203
+ case "string":
204
+ if (!helper__namespace.isString(value)) {
205
+ return false;
206
+ }
207
+ return true;
208
+ case "Object":
209
+ case "object":
210
+ case "Enum":
211
+ case "enum":
212
+ if (helper__namespace.isTrueEmpty(value)) {
213
+ return false;
214
+ }
215
+ return true;
216
+ case "Null":
217
+ case "null":
218
+ if (!helper__namespace.isNull(value)) {
219
+ return false;
220
+ }
221
+ return true;
222
+ case "Undefined":
223
+ case "undefined":
224
+ if (!helper__namespace.isUndefined(value)) {
225
+ return false;
226
+ }
227
+ return true;
228
+ case "Bigint":
229
+ case "bigint":
230
+ if (typeof value !== 'bigint') {
231
+ return false;
232
+ }
233
+ return true;
234
+ default: //any
235
+ return true;
236
+ }
237
+ }
238
+ /**
239
+ * Checks if value is a chinese name.
240
+ *
241
+ * @param {string} value
242
+ * @returns {boolean}
243
+ */
244
+ function cnName(value) {
245
+ const reg = /^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/;
246
+ return reg.test(value);
247
+ }
248
+ /**
249
+ * Checks if value is a idCard number.
250
+ *
251
+ * @param {string} value
252
+ * @returns
253
+ */
254
+ function idNumber(value) {
255
+ if (/^\d{15}$/.test(value)) {
256
+ return true;
257
+ }
258
+ if ((/^\d{17}[0-9X]$/).test(value)) {
259
+ const vs = '1,0,x,9,8,7,6,5,4,3,2'.split(',');
260
+ const ps = '7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2'.split(',');
261
+ const ss = value.toLowerCase().split('');
262
+ let r = 0;
263
+ for (let i = 0; i < 17; i++) {
264
+ r += ps[i] * ss[i];
265
+ }
266
+ const isOk = (vs[r % 11] === ss[17]);
267
+ return isOk;
268
+ }
269
+ return false;
270
+ }
271
+ /**
272
+ * Checks if value is a mobile phone number.
273
+ *
274
+ * @param {string} value
275
+ * @returns {boolean}
276
+ */
277
+ function mobile(value) {
278
+ const reg = /^(13|14|15|16|17|18|19)\d{9}$/;
279
+ return reg.test(value);
280
+ }
281
+ /**
282
+ * Checks if value is a zipCode.
283
+ *
284
+ * @param {string} value
285
+ * @returns {boolean}
286
+ */
287
+ function zipCode(value) {
288
+ const reg = /^\d{6}$/;
289
+ return reg.test(value);
290
+ }
291
+ /**
292
+ * Checks if value is a plateNumber.
293
+ *
294
+ * @param {string} value
295
+ * @returns {boolean}
296
+ */
297
+ function plateNumber(value) {
298
+ // let reg = new RegExp('^(([\u4e00-\u9fa5][a-zA-Z]|[\u4e00-\u9fa5]{2}\d{2}|[\u4e00-\u9fa5]{2}[a-zA-Z])[-]?|([wW][Jj][\u4e00-\u9fa5]{1}[-]?)|([a-zA-Z]{2}))([A-Za-z0-9]{5}|[DdFf][A-HJ-NP-Za-hj-np-z0-9][0-9]{4}|[0-9]{5}[DdFf])$');
299
+ // let xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
300
+ const xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
301
+ // let cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
302
+ const cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
303
+ if (value.length === 7) {
304
+ return cReg.test(value);
305
+ }
306
+ else {
307
+ //新能源车牌
308
+ return xReg.test(value);
309
+ }
310
+ }
311
+
312
+ /*
313
+ * @Description:
314
+ * @Usage:
315
+ * @Author: richen
316
+ * @Date: 2021-11-25 10:47:04
317
+ * @LastEditTime: 2022-02-25 09:51:04
318
+ */
319
+ // constant
320
+ const PARAM_TYPE_KEY = 'PARAM_TYPE_KEY';
321
+ const PARAM_RULE_KEY = 'PARAM_RULE_KEY';
322
+ const PARAM_CHECK_KEY = 'PARAM_CHECK_KEY';
323
+ const ENABLE_VALIDATED = "ENABLE_VALIDATED";
324
+ /**
325
+ * paramterTypes
326
+ *
327
+ * @export
328
+ * @enum {number}
329
+ */
330
+ exports.paramterTypes = void 0;
331
+ (function (paramterTypes) {
332
+ paramterTypes[paramterTypes["Number"] = 0] = "Number";
333
+ paramterTypes[paramterTypes["number"] = 1] = "number";
334
+ paramterTypes[paramterTypes["String"] = 2] = "String";
335
+ paramterTypes[paramterTypes["string"] = 3] = "string";
336
+ paramterTypes[paramterTypes["Boolean"] = 4] = "Boolean";
337
+ paramterTypes[paramterTypes["boolean"] = 5] = "boolean";
338
+ paramterTypes[paramterTypes["Array"] = 6] = "Array";
339
+ paramterTypes[paramterTypes["array"] = 7] = "array";
340
+ paramterTypes[paramterTypes["Tuple"] = 8] = "Tuple";
341
+ paramterTypes[paramterTypes["tuple"] = 9] = "tuple";
342
+ paramterTypes[paramterTypes["Object"] = 10] = "Object";
343
+ paramterTypes[paramterTypes["object"] = 11] = "object";
344
+ paramterTypes[paramterTypes["Enum"] = 12] = "Enum";
345
+ paramterTypes[paramterTypes["enum"] = 13] = "enum";
346
+ paramterTypes[paramterTypes["Bigint"] = 14] = "Bigint";
347
+ paramterTypes[paramterTypes["bigint"] = 15] = "bigint";
348
+ paramterTypes[paramterTypes["Null"] = 16] = "Null";
349
+ paramterTypes[paramterTypes["null"] = 17] = "null";
350
+ paramterTypes[paramterTypes["Undefined"] = 18] = "Undefined";
351
+ paramterTypes[paramterTypes["undefined"] = 19] = "undefined";
352
+ })(exports.paramterTypes || (exports.paramterTypes = {}));
353
+ class ValidateClass {
354
+ constructor() {
355
+ }
356
+ /**
357
+ *
358
+ *
359
+ * @static
360
+ * @returns
361
+ * @memberof ValidateUtil
362
+ */
363
+ static getInstance() {
364
+ return this.instance || (this.instance = new ValidateClass());
365
+ }
366
+ /**
367
+ * validated data vs dto class
368
+ *
369
+ * @param {*} Clazz
370
+ * @param {*} data
371
+ * @param {boolean} [convert=false] auto convert parameters type
372
+ * @returns {Promise<any>}
373
+ * @memberof ValidateClass
374
+ */
375
+ async valid(Clazz, data, convert = false) {
376
+ let obj = {};
377
+ if (data instanceof Clazz) {
378
+ obj = data;
379
+ }
380
+ else {
381
+ obj = plainToClass(Clazz, data, convert);
382
+ }
383
+ let errors = [];
384
+ if (convert) {
385
+ errors = await classValidator.validate(obj);
386
+ }
387
+ else {
388
+ errors = await classValidator.validate(obj, { skipMissingProperties: true });
389
+ }
390
+ if (errors.length > 0) {
391
+ const err = new Error(Object.values(errors[0].constraints)[0]);
392
+ err.code = 400;
393
+ err.status = 400;
394
+ throw err;
395
+ }
396
+ return obj;
397
+ }
398
+ }
399
+ /**
400
+ * ClassValidator for manual
401
+ */
402
+ const ClassValidator = ValidateClass.getInstance();
403
+ /**
404
+ * Validator Functions
405
+ */
406
+ const ValidFuncs = {
407
+ /**
408
+ * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces,
409
+ * tabs, formfeeds, etc.), returns false
410
+ */
411
+ IsNotEmpty: (value) => {
412
+ return !helper__namespace.isEmpty(value);
413
+ },
414
+ /**
415
+ * Checks if a given value is a real date.
416
+ */
417
+ IsDate: (value) => {
418
+ return helper__namespace.isDate(value);
419
+ },
420
+ /**
421
+ * Checks if the string is an email. If given value is not a string, then it returns false.
422
+ */
423
+ IsEmail: (value, options) => {
424
+ return classValidator.isEmail(value, options);
425
+ },
426
+ /**
427
+ * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
428
+ */
429
+ IsIP: (value, version) => {
430
+ return classValidator.isIP(value, version);
431
+ },
432
+ /**
433
+ * Checks if the string is a valid phone number.
434
+ * @param value — the potential phone number string to test
435
+ * @param region 2 characters uppercase country code (e.g. DE, US, CH). If users must enter the intl.
436
+ * prefix (e.g. +41), then you may pass "ZZ" or null as region.
437
+ * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
438
+ * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
439
+ */
440
+ IsPhoneNumber: (value, region) => {
441
+ return classValidator.isPhoneNumber(value, region);
442
+ },
443
+ /**
444
+ * Checks if the string is an url. If given value is not a string, then it returns false.
445
+ */
446
+ IsUrl: (value, options) => {
447
+ return classValidator.isURL(value, options);
448
+ },
449
+ /**
450
+ * check if the string is a hash of type algorithm. Algorithm is one of
451
+ * ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
452
+ */
453
+ IsHash: (value, algorithm) => {
454
+ return classValidator.isHash(value, algorithm);
455
+ },
456
+ /**
457
+ * Checks if value is a chinese name.
458
+ */
459
+ IsCnName: (value) => {
460
+ if (!helper__namespace.isString(value)) {
461
+ return false;
462
+ }
463
+ return cnName(value);
464
+ },
465
+ /**
466
+ * Checks if value is a idcard number.
467
+ */
468
+ IsIdNumber: (value) => {
469
+ if (!helper__namespace.isString(value)) {
470
+ return false;
471
+ }
472
+ return idNumber(value);
473
+ },
474
+ /**
475
+ * Checks if value is a zipCode.
476
+ */
477
+ IsZipCode: (value) => {
478
+ if (!helper__namespace.isString(value)) {
479
+ return false;
480
+ }
481
+ return zipCode(value);
482
+ },
483
+ /**
484
+ * Checks if value is a mobile phone number.
485
+ */
486
+ IsMobile: (value) => {
487
+ if (!helper__namespace.isString(value)) {
488
+ return false;
489
+ }
490
+ return mobile(value);
491
+ },
492
+ /**
493
+ * Checks if value is a plateNumber.
494
+ */
495
+ IsPlateNumber: (value) => {
496
+ if (!helper__namespace.isString(value)) {
497
+ return false;
498
+ }
499
+ return plateNumber(value);
500
+ },
501
+ /**
502
+ * Checks if value matches ("===") the comparison.
503
+ */
504
+ Equals: (value, comparison) => {
505
+ return classValidator.equals(value, comparison);
506
+ },
507
+ /**
508
+ * Checks if value does not match ("!==") the comparison.
509
+ */
510
+ NotEquals: (value, comparison) => {
511
+ return classValidator.notEquals(value, comparison);
512
+ },
513
+ /**
514
+ * Checks if the string contains the seed. If given value is not a string, then it returns false.
515
+ */
516
+ Contains: (value, seed) => {
517
+ return classValidator.contains(value, seed);
518
+ },
519
+ /**
520
+ * Checks if given value is in a array of allowed values.
521
+ */
522
+ IsIn: (value, possibleValues) => {
523
+ return classValidator.isIn(value, possibleValues);
524
+ },
525
+ /**
526
+ * Checks if given value not in a array of allowed values.
527
+ */
528
+ IsNotIn: (value, possibleValues) => {
529
+ return classValidator.isNotIn(value, possibleValues);
530
+ },
531
+ /**
532
+ * Checks if the first number is greater than or equal to the second.
533
+ */
534
+ Gt: (num, min) => {
535
+ return helper__namespace.toNumber(num) > min;
536
+ },
537
+ /**
538
+ * Checks if the first number is less than or equal to the second.
539
+ */
540
+ Lt: (num, max) => {
541
+ return helper__namespace.toNumber(num) < max;
542
+ },
543
+ /**
544
+ * Checks if the first number is greater than or equal to the second.
545
+ */
546
+ Gte: (num, min) => {
547
+ return helper__namespace.toNumber(num) >= min;
548
+ },
549
+ /**
550
+ * Checks if the first number is less than or equal to the second.
551
+ */
552
+ Lte: (num, max) => {
553
+ return helper__namespace.toNumber(num) <= max;
554
+ },
555
+ };
556
+ /**
557
+ * Use functions or built-in rules for validation.
558
+ *
559
+ * @export
560
+ * @param {ValidRules} rule
561
+ * @param {unknown} value
562
+ * @param {(string | ValidOtpions)} [options]
563
+ * @returns {*}
564
+ */
565
+ const FunctionValidator = {
566
+ IsNotEmpty: function (value, options) {
567
+ throw new Error("Function not implemented.");
568
+ },
569
+ IsDate: function (value, options) {
570
+ throw new Error("Function not implemented.");
571
+ },
572
+ IsEmail: function (value, options) {
573
+ throw new Error("Function not implemented.");
574
+ },
575
+ IsIP: function (value, options) {
576
+ throw new Error("Function not implemented.");
577
+ },
578
+ IsPhoneNumber: function (value, options) {
579
+ throw new Error("Function not implemented.");
580
+ },
581
+ IsUrl: function (value, options) {
582
+ throw new Error("Function not implemented.");
583
+ },
584
+ IsHash: function (value, options) {
585
+ throw new Error("Function not implemented.");
586
+ },
587
+ IsCnName: function (value, options) {
588
+ throw new Error("Function not implemented.");
589
+ },
590
+ IsIdNumber: function (value, options) {
591
+ throw new Error("Function not implemented.");
592
+ },
593
+ IsZipCode: function (value, options) {
594
+ throw new Error("Function not implemented.");
595
+ },
596
+ IsMobile: function (value, options) {
597
+ throw new Error("Function not implemented.");
598
+ },
599
+ IsPlateNumber: function (value, options) {
600
+ throw new Error("Function not implemented.");
601
+ },
602
+ Equals: function (value, options) {
603
+ throw new Error("Function not implemented.");
604
+ },
605
+ NotEquals: function (value, options) {
606
+ throw new Error("Function not implemented.");
607
+ },
608
+ Contains: function (value, options) {
609
+ throw new Error("Function not implemented.");
610
+ },
611
+ IsIn: function (value, options) {
612
+ throw new Error("Function not implemented.");
613
+ },
614
+ IsNotIn: function (value, options) {
615
+ throw new Error("Function not implemented.");
616
+ },
617
+ Gt: function (value, options) {
618
+ throw new Error("Function not implemented.");
619
+ },
620
+ Lt: function (value, options) {
621
+ throw new Error("Function not implemented.");
622
+ },
623
+ Gte: function (value, options) {
624
+ throw new Error("Function not implemented.");
625
+ },
626
+ Lte: function (value, options) {
627
+ throw new Error("Function not implemented.");
628
+ }
629
+ };
630
+ Object.keys(ValidFuncs).forEach((key) => {
631
+ FunctionValidator[key] = (value, options) => {
632
+ if (helper__namespace.isString(options)) {
633
+ options = { message: options, value: null };
634
+ }
635
+ if (!ValidFuncs[key](value, options)) {
636
+ const err = new Error(options.message || `ValidatorError: invalid arguments.`);
637
+ err.code = 400;
638
+ err.status = 400;
639
+ throw err;
640
+ }
641
+ };
642
+ });
643
+
644
+ /*
645
+ * @Description:
646
+ * @Usage:
647
+ * @Author: richen
648
+ * @Date: 2021-11-25 10:46:57
649
+ * @LastEditTime: 2022-02-24 15:33:34
650
+ */
651
+ /**
652
+ * Validation parameter's type and values.
653
+ *
654
+ * @export
655
+ * @param {(ValidRules | ValidRules[] | Function)} rule
656
+ * @param {*} [options] If the options type is a string, the value is the error message of the validation rule.
657
+ * Some validation rules require additional parameters, ext: @Valid("Gte", {message:"Requires value greater than or equal to 100", value: 100})
658
+ * @returns {*} {ParameterDecorator}
659
+ */
660
+ function Valid(rule, options) {
661
+ let rules = [];
662
+ if (helper__namespace.isString(rule)) {
663
+ rules = rule.split(",");
664
+ }
665
+ else {
666
+ rules = rule;
667
+ }
668
+ return (target, propertyKey, descriptor) => {
669
+ // 获取成员参数类型
670
+ const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey);
671
+ const type = (paramTypes[descriptor] && paramTypes[descriptor].name) ? paramTypes[descriptor].name : "object";
672
+ if (helper__namespace.isString(options)) {
673
+ options = { message: options, value: null };
674
+ }
675
+ koatty_container.IOCContainer.attachPropertyData(PARAM_RULE_KEY, {
676
+ name: propertyKey,
677
+ rule: rules,
678
+ options,
679
+ index: descriptor,
680
+ type
681
+ }, target, propertyKey);
682
+ };
683
+ }
684
+ /**
685
+ * Validation parameter's type and values from DTO class.
686
+ *
687
+ * @export
688
+ * @returns {MethodDecorator}
689
+ */
690
+ function Validated() {
691
+ return (target, propertyKey, descriptor) => {
692
+ //
693
+ koatty_container.IOCContainer.savePropertyData(PARAM_CHECK_KEY, {
694
+ dtoCheck: 1
695
+ }, target, propertyKey);
696
+ // 获取成员参数类型
697
+ // const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey) || [];
698
+ // const { value, configurable, enumerable } = descriptor;
699
+ // descriptor = {
700
+ // configurable,
701
+ // enumerable,
702
+ // writable: true,
703
+ // value: async function valid(...props: any[]) {
704
+ // const ps: any[] = [];
705
+ // // tslint:disable-next-line: no-unused-expression
706
+ // (props || []).map((value: any, index: number) => {
707
+ // const type = (paramTypes[index] && paramTypes[index].name) ? paramTypes[index].name : "any";
708
+ // if (!paramterTypes[type]) {
709
+ // ps.push(ClassValidator.valid(paramTypes[index], value, true));
710
+ // } else {
711
+ // ps.push(Promise.resolve(value));
712
+ // }
713
+ // });
714
+ // if (ps.length > 0) {
715
+ // props = await Promise.all(ps);
716
+ // }
717
+ // // tslint:disable-next-line: no-invalid-this
718
+ // return value.apply(this, props);
719
+ // }
720
+ // };
721
+ // return descriptor;
722
+ };
723
+ }
724
+ /**
725
+ * Marks property as included in the process of transformation.
726
+ *
727
+ * @export
728
+ * @returns {PropertyDecorator}
729
+ */
730
+ function Expose() {
731
+ return function (object, propertyName) {
732
+ const types = Reflect.getMetadata("design:type", object, propertyName);
733
+ if (types) {
734
+ const originMap = koatty_container.getOriginMetadata(PARAM_TYPE_KEY, object);
735
+ originMap.set(propertyName, types.name);
736
+ }
737
+ };
738
+ }
739
+ /**
740
+ * Identifies that the field needs to be defined
741
+ *
742
+ * @export
743
+ * @returns {PropertyDecorator}
744
+ */
745
+ function IsDefined() {
746
+ return function (object, propertyName) {
747
+ setExpose(object, propertyName);
748
+ };
749
+ }
750
+ /**
751
+ * Checks if value is a chinese name.
752
+ *
753
+ * @export
754
+ * @param {string} property
755
+ * @param {ValidationOptions} [validationOptions]
756
+ * @returns {PropertyDecorator}
757
+ */
758
+ function IsCnName(validationOptions) {
759
+ return function (object, propertyName) {
760
+ setExpose(object, propertyName);
761
+ classValidator.registerDecorator({
762
+ name: "IsCnName",
763
+ target: object.constructor,
764
+ propertyName,
765
+ options: validationOptions,
766
+ validator: {
767
+ validate(value, args) {
768
+ return cnName(value);
769
+ },
770
+ defaultMessage(args) {
771
+ return "invalid parameter ($property).";
772
+ }
773
+ }
774
+ });
775
+ };
776
+ }
777
+ /**
778
+ * Checks if value is a idCard number(chinese).
779
+ *
780
+ * @export
781
+ * @param {string} property
782
+ * @param {ValidationOptions} [validationOptions]
783
+ * @returns {PropertyDecorator}
784
+ */
785
+ function IsIdNumber(validationOptions) {
786
+ return function (object, propertyName) {
787
+ setExpose(object, propertyName);
788
+ classValidator.registerDecorator({
789
+ name: "IsIdNumber",
790
+ target: object.constructor,
791
+ propertyName,
792
+ options: validationOptions,
793
+ validator: {
794
+ validate(value, args) {
795
+ return idNumber(value);
796
+ },
797
+ defaultMessage(args) {
798
+ return "invalid parameter ($property).";
799
+ }
800
+ }
801
+ });
802
+ };
803
+ }
804
+ /**
805
+ * Checks if value is a zipCode(chinese).
806
+ *
807
+ * @export
808
+ * @param {string} property
809
+ * @param {ValidationOptions} [validationOptions]
810
+ * @returns {PropertyDecorator}
811
+ */
812
+ function IsZipCode(validationOptions) {
813
+ return function (object, propertyName) {
814
+ setExpose(object, propertyName);
815
+ classValidator.registerDecorator({
816
+ name: "IsZipCode",
817
+ target: object.constructor,
818
+ propertyName,
819
+ options: validationOptions,
820
+ validator: {
821
+ validate(value, args) {
822
+ return zipCode(value);
823
+ },
824
+ defaultMessage(args) {
825
+ return "invalid parameter ($property).";
826
+ }
827
+ }
828
+ });
829
+ };
830
+ }
831
+ /**
832
+ * Checks if value is a mobile phone number(chinese).
833
+ *
834
+ * @export
835
+ * @param {string} property
836
+ * @param {ValidationOptions} [validationOptions]
837
+ * @returns {PropertyDecorator}
838
+ */
839
+ function IsMobile(validationOptions) {
840
+ return function (object, propertyName) {
841
+ setExpose(object, propertyName);
842
+ classValidator.registerDecorator({
843
+ name: "IsMobile",
844
+ target: object.constructor,
845
+ propertyName,
846
+ options: validationOptions,
847
+ validator: {
848
+ validate(value, args) {
849
+ return mobile(value);
850
+ },
851
+ defaultMessage(args) {
852
+ return "invalid parameter ($property).";
853
+ }
854
+ }
855
+ });
856
+ };
857
+ }
858
+ /**
859
+ * Checks if value is a plate number(chinese).
860
+ *
861
+ * @export
862
+ * @param {string} property
863
+ * @param {ValidationOptions} [validationOptions]
864
+ * @returns {PropertyDecorator}
865
+ */
866
+ function IsPlateNumber(validationOptions) {
867
+ return function (object, propertyName) {
868
+ setExpose(object, propertyName);
869
+ classValidator.registerDecorator({
870
+ name: "IsPlateNumber",
871
+ target: object.constructor,
872
+ propertyName,
873
+ options: validationOptions,
874
+ validator: {
875
+ validate(value, args) {
876
+ return plateNumber(value);
877
+ },
878
+ defaultMessage(args) {
879
+ return "invalid parameter ($property).";
880
+ }
881
+ }
882
+ });
883
+ };
884
+ }
885
+ /**
886
+ * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces, tabs, formfeeds, etc.), returns false.
887
+ *
888
+ * @export
889
+ * @param {ValidationOptions} [validationOptions]
890
+ * @returns {PropertyDecorator}
891
+ */
892
+ function IsNotEmpty(validationOptions) {
893
+ return function (object, propertyName) {
894
+ setExpose(object, propertyName);
895
+ classValidator.registerDecorator({
896
+ name: "IsNotEmpty",
897
+ target: object.constructor,
898
+ propertyName,
899
+ options: validationOptions,
900
+ validator: {
901
+ validate(value, args) {
902
+ return !helper__namespace.isEmpty(value);
903
+ },
904
+ defaultMessage(args) {
905
+ return "invalid parameter ($property).";
906
+ }
907
+ }
908
+ });
909
+ };
910
+ }
911
+ /**
912
+ * Checks if value matches ("===") the comparison.
913
+ *
914
+ * @export
915
+ * @param {*} comparison
916
+ * @param {ValidationOptions} [validationOptions]
917
+ * @returns {PropertyDecorator}
918
+ */
919
+ function Equals(comparison, validationOptions) {
920
+ return function (object, propertyName) {
921
+ setExpose(object, propertyName);
922
+ classValidator.registerDecorator({
923
+ name: "vEquals",
924
+ target: object.constructor,
925
+ propertyName,
926
+ options: validationOptions,
927
+ validator: {
928
+ validate(value, args) {
929
+ return classValidator.equals(value, comparison);
930
+ },
931
+ defaultMessage(args) {
932
+ return `invalid parameter, ($property) must be equals ${comparison}.`;
933
+ }
934
+ }
935
+ });
936
+ };
937
+ }
938
+ /**
939
+ * Checks if value does not match ("!==") the comparison.
940
+ *
941
+ * @export
942
+ * @param {*} comparison
943
+ * @param {ValidationOptions} [validationOptions]
944
+ * @returns {PropertyDecorator}
945
+ */
946
+ function NotEquals(comparison, validationOptions) {
947
+ return function (object, propertyName) {
948
+ setExpose(object, propertyName);
949
+ classValidator.registerDecorator({
950
+ name: "vNotEquals",
951
+ target: object.constructor,
952
+ propertyName,
953
+ options: validationOptions,
954
+ validator: {
955
+ validate(value, args) {
956
+ return classValidator.notEquals(value, comparison);
957
+ },
958
+ defaultMessage(args) {
959
+ return `invalid parameter, ($property) must be not equals ${comparison}.`;
960
+ }
961
+ }
962
+ });
963
+ };
964
+ }
965
+ /**
966
+ * Checks if the string contains the seed.
967
+ *
968
+ * @export
969
+ * @param {string} seed
970
+ * @param {ValidationOptions} [validationOptions]
971
+ * @returns {PropertyDecorator}
972
+ */
973
+ function Contains(seed, validationOptions) {
974
+ return function (object, propertyName) {
975
+ setExpose(object, propertyName);
976
+ classValidator.registerDecorator({
977
+ name: "vContains",
978
+ target: object.constructor,
979
+ propertyName,
980
+ options: validationOptions,
981
+ validator: {
982
+ validate(value, args) {
983
+ return classValidator.contains(value, seed);
984
+ // return typeof value === "string" && (value.indexOf(seed) > -1);
985
+ },
986
+ defaultMessage(args) {
987
+ return `invalid parameter, ($property) must be contains ${seed}.`;
988
+ }
989
+ }
990
+ });
991
+ };
992
+ }
993
+ /**
994
+ * Checks if given value is in a array of allowed values.
995
+ *
996
+ * @export
997
+ * @param {any[]} possibleValues
998
+ * @param {ValidationOptions} [validationOptions]
999
+ * @returns {PropertyDecorator}
1000
+ */
1001
+ function IsIn(possibleValues, validationOptions) {
1002
+ return function (object, propertyName) {
1003
+ setExpose(object, propertyName);
1004
+ classValidator.registerDecorator({
1005
+ name: "vIsIn",
1006
+ target: object.constructor,
1007
+ propertyName,
1008
+ options: validationOptions,
1009
+ validator: {
1010
+ validate(value, args) {
1011
+ return classValidator.isIn(value, possibleValues);
1012
+ },
1013
+ defaultMessage(args) {
1014
+ return `invalid parameter ($property).`;
1015
+ }
1016
+ }
1017
+ });
1018
+ };
1019
+ }
1020
+ /**
1021
+ * Checks if given value not in a array of allowed values.
1022
+ *
1023
+ * @export
1024
+ * @param {any[]} possibleValues
1025
+ * @param {ValidationOptions} [validationOptions]
1026
+ * @returns {PropertyDecorator}
1027
+ */
1028
+ function IsNotIn(possibleValues, validationOptions) {
1029
+ return function (object, propertyName) {
1030
+ setExpose(object, propertyName);
1031
+ classValidator.registerDecorator({
1032
+ name: "vIsNotIn",
1033
+ target: object.constructor,
1034
+ propertyName,
1035
+ options: validationOptions,
1036
+ validator: {
1037
+ validate(value, args) {
1038
+ return classValidator.isNotIn(value, possibleValues);
1039
+ },
1040
+ defaultMessage(args) {
1041
+ return `invalid parameter ($property).`;
1042
+ }
1043
+ }
1044
+ });
1045
+ };
1046
+ }
1047
+ /**
1048
+ * Checks if a given value is a real date.
1049
+ *
1050
+ * @export
1051
+ * @param {ValidationOptions} [validationOptions]
1052
+ * @returns {PropertyDecorator}
1053
+ */
1054
+ function IsDate(validationOptions) {
1055
+ return function (object, propertyName) {
1056
+ setExpose(object, propertyName);
1057
+ classValidator.registerDecorator({
1058
+ name: "vIsDate",
1059
+ target: object.constructor,
1060
+ propertyName,
1061
+ options: validationOptions,
1062
+ validator: {
1063
+ validate(value, args) {
1064
+ return classValidator.isDate(value);
1065
+ },
1066
+ defaultMessage(args) {
1067
+ return `invalid parameter ($property).`;
1068
+ }
1069
+ }
1070
+ });
1071
+ };
1072
+ }
1073
+ /**
1074
+ * Checks if the first number is greater than or equal to the min value.
1075
+ *
1076
+ * @export
1077
+ * @param {number} min
1078
+ * @param {ValidationOptions} [validationOptions]
1079
+ * @returns {PropertyDecorator}
1080
+ */
1081
+ function Gt(min, validationOptions) {
1082
+ return function (object, propertyName) {
1083
+ setExpose(object, propertyName);
1084
+ classValidator.registerDecorator({
1085
+ name: "vMin",
1086
+ target: object.constructor,
1087
+ propertyName,
1088
+ options: validationOptions,
1089
+ validator: {
1090
+ validate(value, args) {
1091
+ return helper__namespace.toNumber(value) > min;
1092
+ },
1093
+ defaultMessage(args) {
1094
+ return `invalid parameter ($property).`;
1095
+ }
1096
+ }
1097
+ });
1098
+ };
1099
+ }
1100
+ /**
1101
+ * Checks if the first number is less than or equal to the max value.
1102
+ *
1103
+ * @export
1104
+ * @param {number} max
1105
+ * @param {ValidationOptions} [validationOptions]
1106
+ * @returns {PropertyDecorator}
1107
+ */
1108
+ function Lt(max, validationOptions) {
1109
+ return function (object, propertyName) {
1110
+ setExpose(object, propertyName);
1111
+ classValidator.registerDecorator({
1112
+ name: "vMax",
1113
+ target: object.constructor,
1114
+ propertyName,
1115
+ options: validationOptions,
1116
+ validator: {
1117
+ validate(value, args) {
1118
+ return helper__namespace.toNumber(value) < max;
1119
+ },
1120
+ defaultMessage(args) {
1121
+ return `invalid parameter ($property).`;
1122
+ }
1123
+ }
1124
+ });
1125
+ };
1126
+ }
1127
+ /**
1128
+ * Checks if the first number is greater than or equal to the min value.
1129
+ *
1130
+ * @export
1131
+ * @param {number} min
1132
+ * @param {ValidationOptions} [validationOptions]
1133
+ * @returns {PropertyDecorator}
1134
+ */
1135
+ function Gte(min, validationOptions) {
1136
+ return function (object, propertyName) {
1137
+ setExpose(object, propertyName);
1138
+ classValidator.registerDecorator({
1139
+ name: "vMin",
1140
+ target: object.constructor,
1141
+ propertyName,
1142
+ options: validationOptions,
1143
+ validator: {
1144
+ validate(value, args) {
1145
+ return helper__namespace.toNumber(value) >= min;
1146
+ },
1147
+ defaultMessage(args) {
1148
+ return `invalid parameter ($property).`;
1149
+ }
1150
+ }
1151
+ });
1152
+ };
1153
+ }
1154
+ /**
1155
+ * Checks if the first number is less than or equal to the max value.
1156
+ *
1157
+ * @export
1158
+ * @param {number} max
1159
+ * @param {ValidationOptions} [validationOptions]
1160
+ * @returns {PropertyDecorator}
1161
+ */
1162
+ function Lte(max, validationOptions) {
1163
+ return function (object, propertyName) {
1164
+ setExpose(object, propertyName);
1165
+ classValidator.registerDecorator({
1166
+ name: "vMax",
1167
+ target: object.constructor,
1168
+ propertyName,
1169
+ options: validationOptions,
1170
+ validator: {
1171
+ validate(value, args) {
1172
+ return helper__namespace.toNumber(value) <= max;
1173
+ },
1174
+ defaultMessage(args) {
1175
+ return `invalid parameter ($property).`;
1176
+ }
1177
+ }
1178
+ });
1179
+ };
1180
+ }
1181
+ /**
1182
+ * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
1183
+ * If given value is not a string, then it returns false.
1184
+ *
1185
+ * @export
1186
+ * @param {number} min
1187
+ * @param {number} [max]
1188
+ * @param {ValidationOptions} [validationOptions]
1189
+ * @returns {PropertyDecorator}
1190
+ */
1191
+ function Length(min, max, validationOptions) {
1192
+ return function (object, propertyName) {
1193
+ setExpose(object, propertyName);
1194
+ classValidator.registerDecorator({
1195
+ name: "vLength",
1196
+ target: object.constructor,
1197
+ propertyName,
1198
+ options: validationOptions,
1199
+ validator: {
1200
+ validate(value, args) {
1201
+ return classValidator.length(value, min, max);
1202
+ },
1203
+ defaultMessage(args) {
1204
+ return `invalid parameter ($property).`;
1205
+ }
1206
+ }
1207
+ });
1208
+ };
1209
+ }
1210
+ /**
1211
+ * Checks if the string is an email. If given value is not a string, then it returns false.
1212
+ *
1213
+ * @export
1214
+ * @param {IsEmailOptions} [options]
1215
+ * @param {ValidationOptions} [validationOptions]
1216
+ * @returns {PropertyDecorator}
1217
+ */
1218
+ function IsEmail(options, validationOptions) {
1219
+ return function (object, propertyName) {
1220
+ setExpose(object, propertyName);
1221
+ classValidator.registerDecorator({
1222
+ name: "vIsEmail",
1223
+ target: object.constructor,
1224
+ propertyName,
1225
+ options: validationOptions,
1226
+ validator: {
1227
+ validate(value, args) {
1228
+ return classValidator.isEmail(value);
1229
+ },
1230
+ defaultMessage(args) {
1231
+ return `invalid parameter ($property).`;
1232
+ }
1233
+ }
1234
+ });
1235
+ };
1236
+ }
1237
+ /**
1238
+ * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
1239
+ *
1240
+ * @export
1241
+ * @param {number} [version]
1242
+ * @param {ValidationOptions} [validationOptions]
1243
+ * @returns {PropertyDecorator}
1244
+ */
1245
+ function IsIP(version, validationOptions) {
1246
+ return function (object, propertyName) {
1247
+ setExpose(object, propertyName);
1248
+ classValidator.registerDecorator({
1249
+ name: "vIsIP",
1250
+ target: object.constructor,
1251
+ propertyName,
1252
+ options: validationOptions,
1253
+ validator: {
1254
+ validate(value, args) {
1255
+ return classValidator.isIP(value, version);
1256
+ },
1257
+ defaultMessage(args) {
1258
+ return `invalid parameter ($property).`;
1259
+ }
1260
+ }
1261
+ });
1262
+ };
1263
+ }
1264
+ /**
1265
+ * Checks if the string is a valid phone number.
1266
+ *
1267
+ * @export
1268
+ * @param {string} {string} region 2 characters uppercase country code (e.g. DE, US, CH).
1269
+ * If users must enter the intl. prefix (e.g. +41), then you may pass "ZZ" or null as region.
1270
+ * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
1271
+ * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
1272
+ * @param {ValidationOptions} [validationOptions]
1273
+ * @returns {PropertyDecorator}
1274
+ */
1275
+ function IsPhoneNumber(region, validationOptions) {
1276
+ return function (object, propertyName) {
1277
+ setExpose(object, propertyName);
1278
+ classValidator.registerDecorator({
1279
+ name: "vIsPhoneNumber",
1280
+ target: object.constructor,
1281
+ propertyName,
1282
+ options: validationOptions,
1283
+ validator: {
1284
+ validate(value, args) {
1285
+ return classValidator.isPhoneNumber(value, region);
1286
+ },
1287
+ defaultMessage(args) {
1288
+ return `invalid parameter ($property).`;
1289
+ }
1290
+ }
1291
+ });
1292
+ };
1293
+ }
1294
+ /**
1295
+ * Checks if the string is an url.
1296
+ *
1297
+ * @export
1298
+ * @param {IsURLOptions} [options]
1299
+ * @param {ValidationOptions} [validationOptions]
1300
+ * @returns {PropertyDecorator}
1301
+ */
1302
+ function IsUrl(options, validationOptions) {
1303
+ return function (object, propertyName) {
1304
+ setExpose(object, propertyName);
1305
+ classValidator.registerDecorator({
1306
+ name: "vIsUrl",
1307
+ target: object.constructor,
1308
+ propertyName,
1309
+ options: validationOptions,
1310
+ validator: {
1311
+ validate(value, args) {
1312
+ return classValidator.isURL(value, options);
1313
+ },
1314
+ defaultMessage(args) {
1315
+ return `invalid parameter ($property).`;
1316
+ }
1317
+ }
1318
+ });
1319
+ };
1320
+ }
1321
+ /**
1322
+ * check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256',
1323
+ * 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
1324
+ *
1325
+ * @export
1326
+ * @param {HashAlgorithm} algorithm
1327
+ * @param {ValidationOptions} [validationOptions]
1328
+ * @returns {PropertyDecorator}
1329
+ */
1330
+ function IsHash(algorithm, validationOptions) {
1331
+ return function (object, propertyName) {
1332
+ setExpose(object, propertyName);
1333
+ classValidator.registerDecorator({
1334
+ name: "vIsHash",
1335
+ target: object.constructor,
1336
+ propertyName,
1337
+ options: validationOptions,
1338
+ validator: {
1339
+ validate(value, args) {
1340
+ return classValidator.isHash(value, algorithm);
1341
+ },
1342
+ defaultMessage(args) {
1343
+ return `invalid parameter, ($property) must be is an ${algorithm} Hash string.`;
1344
+ }
1345
+ }
1346
+ });
1347
+ };
1348
+ }
1349
+
1350
+ exports.ClassValidator = ClassValidator;
1351
+ exports.Contains = Contains;
1352
+ exports.ENABLE_VALIDATED = ENABLE_VALIDATED;
1353
+ exports.Equals = Equals;
1354
+ exports.Expose = Expose;
1355
+ exports.FunctionValidator = FunctionValidator;
1356
+ exports.Gt = Gt;
1357
+ exports.Gte = Gte;
1358
+ exports.IsCnName = IsCnName;
1359
+ exports.IsDate = IsDate;
1360
+ exports.IsDefined = IsDefined;
1361
+ exports.IsEmail = IsEmail;
1362
+ exports.IsHash = IsHash;
1363
+ exports.IsIP = IsIP;
1364
+ exports.IsIdNumber = IsIdNumber;
1365
+ exports.IsIn = IsIn;
1366
+ exports.IsMobile = IsMobile;
1367
+ exports.IsNotEmpty = IsNotEmpty;
1368
+ exports.IsNotIn = IsNotIn;
1369
+ exports.IsPhoneNumber = IsPhoneNumber;
1370
+ exports.IsPlateNumber = IsPlateNumber;
1371
+ exports.IsUrl = IsUrl;
1372
+ exports.IsZipCode = IsZipCode;
1373
+ exports.Length = Length;
1374
+ exports.Lt = Lt;
1375
+ exports.Lte = Lte;
1376
+ exports.NotEquals = NotEquals;
1377
+ exports.PARAM_CHECK_KEY = PARAM_CHECK_KEY;
1378
+ exports.PARAM_RULE_KEY = PARAM_RULE_KEY;
1379
+ exports.PARAM_TYPE_KEY = PARAM_TYPE_KEY;
1380
+ exports.Valid = Valid;
1381
+ exports.Validated = Validated;
1382
+ exports.checkParamsType = checkParamsType;
1383
+ exports.convertDtoParamsType = convertDtoParamsType;
1384
+ exports.convertParamsType = convertParamsType;
1385
+ exports.plainToClass = plainToClass;