koatty_validation 1.0.12 → 1.2.2

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,21 +1,1379 @@
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.getOriginMetadata = 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
- Object.defineProperty(exports, "getOriginMetadata", { enumerable: true, get: function () { return util_1.getOriginMetadata; } });
20
- // export decorators from class-validator
21
- //# sourceMappingURL=index.js.map
1
+ /*!
2
+ * @Author: richen
3
+ * @Date: 2022-02-25 10:58:54
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 10:33:20
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
+ throw new Error(Object.values(errors[0].constraints)[0]);
392
+ }
393
+ return obj;
394
+ }
395
+ }
396
+ /**
397
+ * ClassValidator for manual
398
+ */
399
+ const ClassValidator = ValidateClass.getInstance();
400
+ /**
401
+ * Validator Functions
402
+ */
403
+ const ValidFuncs = {
404
+ /**
405
+ * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces,
406
+ * tabs, formfeeds, etc.), returns false
407
+ */
408
+ IsNotEmpty: (value) => {
409
+ return !helper__namespace.isEmpty(value);
410
+ },
411
+ /**
412
+ * Checks if a given value is a real date.
413
+ */
414
+ IsDate: (value) => {
415
+ return helper__namespace.isDate(value);
416
+ },
417
+ /**
418
+ * Checks if the string is an email. If given value is not a string, then it returns false.
419
+ */
420
+ IsEmail: (value, options) => {
421
+ return classValidator.isEmail(value, options);
422
+ },
423
+ /**
424
+ * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
425
+ */
426
+ IsIP: (value, version) => {
427
+ return classValidator.isIP(value, version);
428
+ },
429
+ /**
430
+ * Checks if the string is a valid phone number.
431
+ * @param value — the potential phone number string to test
432
+ * @param region 2 characters uppercase country code (e.g. DE, US, CH). If users must enter the intl.
433
+ * prefix (e.g. +41), then you may pass "ZZ" or null as region.
434
+ * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
435
+ * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
436
+ */
437
+ IsPhoneNumber: (value, region) => {
438
+ return classValidator.isPhoneNumber(value, region);
439
+ },
440
+ /**
441
+ * Checks if the string is an url. If given value is not a string, then it returns false.
442
+ */
443
+ IsUrl: (value, options) => {
444
+ return classValidator.isURL(value, options);
445
+ },
446
+ /**
447
+ * check if the string is a hash of type algorithm. Algorithm is one of
448
+ * ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
449
+ */
450
+ IsHash: (value, algorithm) => {
451
+ return classValidator.isHash(value, algorithm);
452
+ },
453
+ /**
454
+ * Checks if value is a chinese name.
455
+ */
456
+ IsCnName: (value) => {
457
+ if (!helper__namespace.isString(value)) {
458
+ return false;
459
+ }
460
+ return cnName(value);
461
+ },
462
+ /**
463
+ * Checks if value is a idcard number.
464
+ */
465
+ IsIdNumber: (value) => {
466
+ if (!helper__namespace.isString(value)) {
467
+ return false;
468
+ }
469
+ return idNumber(value);
470
+ },
471
+ /**
472
+ * Checks if value is a zipCode.
473
+ */
474
+ IsZipCode: (value) => {
475
+ if (!helper__namespace.isString(value)) {
476
+ return false;
477
+ }
478
+ return zipCode(value);
479
+ },
480
+ /**
481
+ * Checks if value is a mobile phone number.
482
+ */
483
+ IsMobile: (value) => {
484
+ if (!helper__namespace.isString(value)) {
485
+ return false;
486
+ }
487
+ return mobile(value);
488
+ },
489
+ /**
490
+ * Checks if value is a plateNumber.
491
+ */
492
+ IsPlateNumber: (value) => {
493
+ if (!helper__namespace.isString(value)) {
494
+ return false;
495
+ }
496
+ return plateNumber(value);
497
+ },
498
+ /**
499
+ * Checks if value matches ("===") the comparison.
500
+ */
501
+ Equals: (value, comparison) => {
502
+ return classValidator.equals(value, comparison);
503
+ },
504
+ /**
505
+ * Checks if value does not match ("!==") the comparison.
506
+ */
507
+ NotEquals: (value, comparison) => {
508
+ return classValidator.notEquals(value, comparison);
509
+ },
510
+ /**
511
+ * Checks if the string contains the seed. If given value is not a string, then it returns false.
512
+ */
513
+ Contains: (value, seed) => {
514
+ return classValidator.contains(value, seed);
515
+ },
516
+ /**
517
+ * Checks if given value is in a array of allowed values.
518
+ */
519
+ IsIn: (value, possibleValues) => {
520
+ return classValidator.isIn(value, possibleValues);
521
+ },
522
+ /**
523
+ * Checks if given value not in a array of allowed values.
524
+ */
525
+ IsNotIn: (value, possibleValues) => {
526
+ return classValidator.isNotIn(value, possibleValues);
527
+ },
528
+ /**
529
+ * Checks if the first number is greater than or equal to the second.
530
+ */
531
+ Gt: (num, min) => {
532
+ return helper__namespace.toNumber(num) > min;
533
+ },
534
+ /**
535
+ * Checks if the first number is less than or equal to the second.
536
+ */
537
+ Lt: (num, max) => {
538
+ return helper__namespace.toNumber(num) < max;
539
+ },
540
+ /**
541
+ * Checks if the first number is greater than or equal to the second.
542
+ */
543
+ Gte: (num, min) => {
544
+ return helper__namespace.toNumber(num) >= min;
545
+ },
546
+ /**
547
+ * Checks if the first number is less than or equal to the second.
548
+ */
549
+ Lte: (num, max) => {
550
+ return helper__namespace.toNumber(num) <= max;
551
+ },
552
+ };
553
+ /**
554
+ * Use functions or built-in rules for validation.
555
+ *
556
+ * @export
557
+ * @param {ValidRules} rule
558
+ * @param {unknown} value
559
+ * @param {(string | ValidOtpions)} [options]
560
+ * @returns {*}
561
+ */
562
+ const FunctionValidator = {
563
+ IsNotEmpty: function (value, options) {
564
+ throw new Error("Function not implemented.");
565
+ },
566
+ IsDate: function (value, options) {
567
+ throw new Error("Function not implemented.");
568
+ },
569
+ IsEmail: function (value, options) {
570
+ throw new Error("Function not implemented.");
571
+ },
572
+ IsIP: function (value, options) {
573
+ throw new Error("Function not implemented.");
574
+ },
575
+ IsPhoneNumber: function (value, options) {
576
+ throw new Error("Function not implemented.");
577
+ },
578
+ IsUrl: function (value, options) {
579
+ throw new Error("Function not implemented.");
580
+ },
581
+ IsHash: function (value, options) {
582
+ throw new Error("Function not implemented.");
583
+ },
584
+ IsCnName: function (value, options) {
585
+ throw new Error("Function not implemented.");
586
+ },
587
+ IsIdNumber: function (value, options) {
588
+ throw new Error("Function not implemented.");
589
+ },
590
+ IsZipCode: function (value, options) {
591
+ throw new Error("Function not implemented.");
592
+ },
593
+ IsMobile: function (value, options) {
594
+ throw new Error("Function not implemented.");
595
+ },
596
+ IsPlateNumber: function (value, options) {
597
+ throw new Error("Function not implemented.");
598
+ },
599
+ Equals: function (value, options) {
600
+ throw new Error("Function not implemented.");
601
+ },
602
+ NotEquals: function (value, options) {
603
+ throw new Error("Function not implemented.");
604
+ },
605
+ Contains: function (value, options) {
606
+ throw new Error("Function not implemented.");
607
+ },
608
+ IsIn: function (value, options) {
609
+ throw new Error("Function not implemented.");
610
+ },
611
+ IsNotIn: function (value, options) {
612
+ throw new Error("Function not implemented.");
613
+ },
614
+ Gt: function (value, options) {
615
+ throw new Error("Function not implemented.");
616
+ },
617
+ Lt: function (value, options) {
618
+ throw new Error("Function not implemented.");
619
+ },
620
+ Gte: function (value, options) {
621
+ throw new Error("Function not implemented.");
622
+ },
623
+ Lte: function (value, options) {
624
+ throw new Error("Function not implemented.");
625
+ }
626
+ };
627
+ Object.keys(ValidFuncs).forEach((key) => {
628
+ FunctionValidator[key] = (value, options) => {
629
+ if (helper__namespace.isString(options)) {
630
+ options = { message: options, value: null };
631
+ }
632
+ if (!ValidFuncs[key](value, options)) {
633
+ throw new Error(options.message || `ValidatorError: invalid arguments.`);
634
+ }
635
+ };
636
+ });
637
+
638
+ /*
639
+ * @Description:
640
+ * @Usage:
641
+ * @Author: richen
642
+ * @Date: 2021-11-25 10:46:57
643
+ * @LastEditTime: 2022-02-24 15:33:34
644
+ */
645
+ /**
646
+ * Validation parameter's type and values.
647
+ *
648
+ * @export
649
+ * @param {(ValidRules | ValidRules[] | Function)} rule
650
+ * @param {*} [options] If the options type is a string, the value is the error message of the validation rule.
651
+ * Some validation rules require additional parameters, ext: @Valid("Gte", {message:"Requires value greater than or equal to 100", value: 100})
652
+ * @returns {*} {ParameterDecorator}
653
+ */
654
+ function Valid(rule, options) {
655
+ let rules = [];
656
+ if (helper__namespace.isString(rule)) {
657
+ rules = rule.split(",");
658
+ }
659
+ else {
660
+ rules = rule;
661
+ }
662
+ return (target, propertyKey, descriptor) => {
663
+ // 获取成员参数类型
664
+ const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey);
665
+ const type = (paramTypes[descriptor] && paramTypes[descriptor].name) ? paramTypes[descriptor].name : "object";
666
+ if (helper__namespace.isString(options)) {
667
+ options = { message: options, value: null };
668
+ }
669
+ koatty_container.IOCContainer.attachPropertyData(PARAM_RULE_KEY, {
670
+ name: propertyKey,
671
+ rule: rules,
672
+ options,
673
+ index: descriptor,
674
+ type
675
+ }, target, propertyKey);
676
+ };
677
+ }
678
+ /**
679
+ * Validation parameter's type and values from DTO class.
680
+ *
681
+ * @export
682
+ * @returns {MethodDecorator}
683
+ */
684
+ function Validated() {
685
+ return (target, propertyKey, descriptor) => {
686
+ //
687
+ koatty_container.IOCContainer.savePropertyData(PARAM_CHECK_KEY, {
688
+ dtoCheck: 1
689
+ }, target, propertyKey);
690
+ // 获取成员参数类型
691
+ // const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey) || [];
692
+ // const { value, configurable, enumerable } = descriptor;
693
+ // descriptor = {
694
+ // configurable,
695
+ // enumerable,
696
+ // writable: true,
697
+ // value: async function valid(...props: any[]) {
698
+ // const ps: any[] = [];
699
+ // // tslint:disable-next-line: no-unused-expression
700
+ // (props || []).map((value: any, index: number) => {
701
+ // const type = (paramTypes[index] && paramTypes[index].name) ? paramTypes[index].name : "any";
702
+ // if (!paramterTypes[type]) {
703
+ // ps.push(ClassValidator.valid(paramTypes[index], value, true));
704
+ // } else {
705
+ // ps.push(Promise.resolve(value));
706
+ // }
707
+ // });
708
+ // if (ps.length > 0) {
709
+ // props = await Promise.all(ps);
710
+ // }
711
+ // // tslint:disable-next-line: no-invalid-this
712
+ // return value.apply(this, props);
713
+ // }
714
+ // };
715
+ // return descriptor;
716
+ };
717
+ }
718
+ /**
719
+ * Marks property as included in the process of transformation.
720
+ *
721
+ * @export
722
+ * @returns {PropertyDecorator}
723
+ */
724
+ function Expose() {
725
+ return function (object, propertyName) {
726
+ const types = Reflect.getMetadata("design:type", object, propertyName);
727
+ if (types) {
728
+ const originMap = koatty_container.getOriginMetadata(PARAM_TYPE_KEY, object);
729
+ originMap.set(propertyName, types.name);
730
+ }
731
+ };
732
+ }
733
+ /**
734
+ * Identifies that the field needs to be defined
735
+ *
736
+ * @export
737
+ * @returns {PropertyDecorator}
738
+ */
739
+ function IsDefined() {
740
+ return function (object, propertyName) {
741
+ setExpose(object, propertyName);
742
+ };
743
+ }
744
+ /**
745
+ * Checks if value is a chinese name.
746
+ *
747
+ * @export
748
+ * @param {string} property
749
+ * @param {ValidationOptions} [validationOptions]
750
+ * @returns {PropertyDecorator}
751
+ */
752
+ function IsCnName(validationOptions) {
753
+ return function (object, propertyName) {
754
+ setExpose(object, propertyName);
755
+ classValidator.registerDecorator({
756
+ name: "IsCnName",
757
+ target: object.constructor,
758
+ propertyName,
759
+ options: validationOptions,
760
+ validator: {
761
+ validate(value, args) {
762
+ return cnName(value);
763
+ },
764
+ defaultMessage(args) {
765
+ return "invalid parameter ($property).";
766
+ }
767
+ }
768
+ });
769
+ };
770
+ }
771
+ /**
772
+ * Checks if value is a idCard number(chinese).
773
+ *
774
+ * @export
775
+ * @param {string} property
776
+ * @param {ValidationOptions} [validationOptions]
777
+ * @returns {PropertyDecorator}
778
+ */
779
+ function IsIdNumber(validationOptions) {
780
+ return function (object, propertyName) {
781
+ setExpose(object, propertyName);
782
+ classValidator.registerDecorator({
783
+ name: "IsIdNumber",
784
+ target: object.constructor,
785
+ propertyName,
786
+ options: validationOptions,
787
+ validator: {
788
+ validate(value, args) {
789
+ return idNumber(value);
790
+ },
791
+ defaultMessage(args) {
792
+ return "invalid parameter ($property).";
793
+ }
794
+ }
795
+ });
796
+ };
797
+ }
798
+ /**
799
+ * Checks if value is a zipCode(chinese).
800
+ *
801
+ * @export
802
+ * @param {string} property
803
+ * @param {ValidationOptions} [validationOptions]
804
+ * @returns {PropertyDecorator}
805
+ */
806
+ function IsZipCode(validationOptions) {
807
+ return function (object, propertyName) {
808
+ setExpose(object, propertyName);
809
+ classValidator.registerDecorator({
810
+ name: "IsZipCode",
811
+ target: object.constructor,
812
+ propertyName,
813
+ options: validationOptions,
814
+ validator: {
815
+ validate(value, args) {
816
+ return zipCode(value);
817
+ },
818
+ defaultMessage(args) {
819
+ return "invalid parameter ($property).";
820
+ }
821
+ }
822
+ });
823
+ };
824
+ }
825
+ /**
826
+ * Checks if value is a mobile phone number(chinese).
827
+ *
828
+ * @export
829
+ * @param {string} property
830
+ * @param {ValidationOptions} [validationOptions]
831
+ * @returns {PropertyDecorator}
832
+ */
833
+ function IsMobile(validationOptions) {
834
+ return function (object, propertyName) {
835
+ setExpose(object, propertyName);
836
+ classValidator.registerDecorator({
837
+ name: "IsMobile",
838
+ target: object.constructor,
839
+ propertyName,
840
+ options: validationOptions,
841
+ validator: {
842
+ validate(value, args) {
843
+ return mobile(value);
844
+ },
845
+ defaultMessage(args) {
846
+ return "invalid parameter ($property).";
847
+ }
848
+ }
849
+ });
850
+ };
851
+ }
852
+ /**
853
+ * Checks if value is a plate number(chinese).
854
+ *
855
+ * @export
856
+ * @param {string} property
857
+ * @param {ValidationOptions} [validationOptions]
858
+ * @returns {PropertyDecorator}
859
+ */
860
+ function IsPlateNumber(validationOptions) {
861
+ return function (object, propertyName) {
862
+ setExpose(object, propertyName);
863
+ classValidator.registerDecorator({
864
+ name: "IsPlateNumber",
865
+ target: object.constructor,
866
+ propertyName,
867
+ options: validationOptions,
868
+ validator: {
869
+ validate(value, args) {
870
+ return plateNumber(value);
871
+ },
872
+ defaultMessage(args) {
873
+ return "invalid parameter ($property).";
874
+ }
875
+ }
876
+ });
877
+ };
878
+ }
879
+ /**
880
+ * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces, tabs, formfeeds, etc.), returns false.
881
+ *
882
+ * @export
883
+ * @param {ValidationOptions} [validationOptions]
884
+ * @returns {PropertyDecorator}
885
+ */
886
+ function IsNotEmpty(validationOptions) {
887
+ return function (object, propertyName) {
888
+ setExpose(object, propertyName);
889
+ classValidator.registerDecorator({
890
+ name: "IsNotEmpty",
891
+ target: object.constructor,
892
+ propertyName,
893
+ options: validationOptions,
894
+ validator: {
895
+ validate(value, args) {
896
+ return !helper__namespace.isEmpty(value);
897
+ },
898
+ defaultMessage(args) {
899
+ return "invalid parameter ($property).";
900
+ }
901
+ }
902
+ });
903
+ };
904
+ }
905
+ /**
906
+ * Checks if value matches ("===") the comparison.
907
+ *
908
+ * @export
909
+ * @param {*} comparison
910
+ * @param {ValidationOptions} [validationOptions]
911
+ * @returns {PropertyDecorator}
912
+ */
913
+ function Equals(comparison, validationOptions) {
914
+ return function (object, propertyName) {
915
+ setExpose(object, propertyName);
916
+ classValidator.registerDecorator({
917
+ name: "vEquals",
918
+ target: object.constructor,
919
+ propertyName,
920
+ options: validationOptions,
921
+ validator: {
922
+ validate(value, args) {
923
+ return classValidator.equals(value, comparison);
924
+ },
925
+ defaultMessage(args) {
926
+ return `invalid parameter, ($property) must be equals ${comparison}.`;
927
+ }
928
+ }
929
+ });
930
+ };
931
+ }
932
+ /**
933
+ * Checks if value does not match ("!==") the comparison.
934
+ *
935
+ * @export
936
+ * @param {*} comparison
937
+ * @param {ValidationOptions} [validationOptions]
938
+ * @returns {PropertyDecorator}
939
+ */
940
+ function NotEquals(comparison, validationOptions) {
941
+ return function (object, propertyName) {
942
+ setExpose(object, propertyName);
943
+ classValidator.registerDecorator({
944
+ name: "vNotEquals",
945
+ target: object.constructor,
946
+ propertyName,
947
+ options: validationOptions,
948
+ validator: {
949
+ validate(value, args) {
950
+ return classValidator.notEquals(value, comparison);
951
+ },
952
+ defaultMessage(args) {
953
+ return `invalid parameter, ($property) must be not equals ${comparison}.`;
954
+ }
955
+ }
956
+ });
957
+ };
958
+ }
959
+ /**
960
+ * Checks if the string contains the seed.
961
+ *
962
+ * @export
963
+ * @param {string} seed
964
+ * @param {ValidationOptions} [validationOptions]
965
+ * @returns {PropertyDecorator}
966
+ */
967
+ function Contains(seed, validationOptions) {
968
+ return function (object, propertyName) {
969
+ setExpose(object, propertyName);
970
+ classValidator.registerDecorator({
971
+ name: "vContains",
972
+ target: object.constructor,
973
+ propertyName,
974
+ options: validationOptions,
975
+ validator: {
976
+ validate(value, args) {
977
+ return classValidator.contains(value, seed);
978
+ // return typeof value === "string" && (value.indexOf(seed) > -1);
979
+ },
980
+ defaultMessage(args) {
981
+ return `invalid parameter, ($property) must be contains ${seed}.`;
982
+ }
983
+ }
984
+ });
985
+ };
986
+ }
987
+ /**
988
+ * Checks if given value is in a array of allowed values.
989
+ *
990
+ * @export
991
+ * @param {any[]} possibleValues
992
+ * @param {ValidationOptions} [validationOptions]
993
+ * @returns {PropertyDecorator}
994
+ */
995
+ function IsIn(possibleValues, validationOptions) {
996
+ return function (object, propertyName) {
997
+ setExpose(object, propertyName);
998
+ classValidator.registerDecorator({
999
+ name: "vIsIn",
1000
+ target: object.constructor,
1001
+ propertyName,
1002
+ options: validationOptions,
1003
+ validator: {
1004
+ validate(value, args) {
1005
+ return classValidator.isIn(value, possibleValues);
1006
+ },
1007
+ defaultMessage(args) {
1008
+ return `invalid parameter ($property).`;
1009
+ }
1010
+ }
1011
+ });
1012
+ };
1013
+ }
1014
+ /**
1015
+ * Checks if given value not in a array of allowed values.
1016
+ *
1017
+ * @export
1018
+ * @param {any[]} possibleValues
1019
+ * @param {ValidationOptions} [validationOptions]
1020
+ * @returns {PropertyDecorator}
1021
+ */
1022
+ function IsNotIn(possibleValues, validationOptions) {
1023
+ return function (object, propertyName) {
1024
+ setExpose(object, propertyName);
1025
+ classValidator.registerDecorator({
1026
+ name: "vIsNotIn",
1027
+ target: object.constructor,
1028
+ propertyName,
1029
+ options: validationOptions,
1030
+ validator: {
1031
+ validate(value, args) {
1032
+ return classValidator.isNotIn(value, possibleValues);
1033
+ },
1034
+ defaultMessage(args) {
1035
+ return `invalid parameter ($property).`;
1036
+ }
1037
+ }
1038
+ });
1039
+ };
1040
+ }
1041
+ /**
1042
+ * Checks if a given value is a real date.
1043
+ *
1044
+ * @export
1045
+ * @param {ValidationOptions} [validationOptions]
1046
+ * @returns {PropertyDecorator}
1047
+ */
1048
+ function IsDate(validationOptions) {
1049
+ return function (object, propertyName) {
1050
+ setExpose(object, propertyName);
1051
+ classValidator.registerDecorator({
1052
+ name: "vIsDate",
1053
+ target: object.constructor,
1054
+ propertyName,
1055
+ options: validationOptions,
1056
+ validator: {
1057
+ validate(value, args) {
1058
+ return classValidator.isDate(value);
1059
+ },
1060
+ defaultMessage(args) {
1061
+ return `invalid parameter ($property).`;
1062
+ }
1063
+ }
1064
+ });
1065
+ };
1066
+ }
1067
+ /**
1068
+ * Checks if the first number is greater than or equal to the min value.
1069
+ *
1070
+ * @export
1071
+ * @param {number} min
1072
+ * @param {ValidationOptions} [validationOptions]
1073
+ * @returns {PropertyDecorator}
1074
+ */
1075
+ function Gt(min, validationOptions) {
1076
+ return function (object, propertyName) {
1077
+ setExpose(object, propertyName);
1078
+ classValidator.registerDecorator({
1079
+ name: "vMin",
1080
+ target: object.constructor,
1081
+ propertyName,
1082
+ options: validationOptions,
1083
+ validator: {
1084
+ validate(value, args) {
1085
+ return helper__namespace.toNumber(value) > min;
1086
+ },
1087
+ defaultMessage(args) {
1088
+ return `invalid parameter ($property).`;
1089
+ }
1090
+ }
1091
+ });
1092
+ };
1093
+ }
1094
+ /**
1095
+ * Checks if the first number is less than or equal to the max value.
1096
+ *
1097
+ * @export
1098
+ * @param {number} max
1099
+ * @param {ValidationOptions} [validationOptions]
1100
+ * @returns {PropertyDecorator}
1101
+ */
1102
+ function Lt(max, validationOptions) {
1103
+ return function (object, propertyName) {
1104
+ setExpose(object, propertyName);
1105
+ classValidator.registerDecorator({
1106
+ name: "vMax",
1107
+ target: object.constructor,
1108
+ propertyName,
1109
+ options: validationOptions,
1110
+ validator: {
1111
+ validate(value, args) {
1112
+ return helper__namespace.toNumber(value) < max;
1113
+ },
1114
+ defaultMessage(args) {
1115
+ return `invalid parameter ($property).`;
1116
+ }
1117
+ }
1118
+ });
1119
+ };
1120
+ }
1121
+ /**
1122
+ * Checks if the first number is greater than or equal to the min value.
1123
+ *
1124
+ * @export
1125
+ * @param {number} min
1126
+ * @param {ValidationOptions} [validationOptions]
1127
+ * @returns {PropertyDecorator}
1128
+ */
1129
+ function Gte(min, validationOptions) {
1130
+ return function (object, propertyName) {
1131
+ setExpose(object, propertyName);
1132
+ classValidator.registerDecorator({
1133
+ name: "vMin",
1134
+ target: object.constructor,
1135
+ propertyName,
1136
+ options: validationOptions,
1137
+ validator: {
1138
+ validate(value, args) {
1139
+ return helper__namespace.toNumber(value) >= min;
1140
+ },
1141
+ defaultMessage(args) {
1142
+ return `invalid parameter ($property).`;
1143
+ }
1144
+ }
1145
+ });
1146
+ };
1147
+ }
1148
+ /**
1149
+ * Checks if the first number is less than or equal to the max value.
1150
+ *
1151
+ * @export
1152
+ * @param {number} max
1153
+ * @param {ValidationOptions} [validationOptions]
1154
+ * @returns {PropertyDecorator}
1155
+ */
1156
+ function Lte(max, validationOptions) {
1157
+ return function (object, propertyName) {
1158
+ setExpose(object, propertyName);
1159
+ classValidator.registerDecorator({
1160
+ name: "vMax",
1161
+ target: object.constructor,
1162
+ propertyName,
1163
+ options: validationOptions,
1164
+ validator: {
1165
+ validate(value, args) {
1166
+ return helper__namespace.toNumber(value) <= max;
1167
+ },
1168
+ defaultMessage(args) {
1169
+ return `invalid parameter ($property).`;
1170
+ }
1171
+ }
1172
+ });
1173
+ };
1174
+ }
1175
+ /**
1176
+ * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
1177
+ * If given value is not a string, then it returns false.
1178
+ *
1179
+ * @export
1180
+ * @param {number} min
1181
+ * @param {number} [max]
1182
+ * @param {ValidationOptions} [validationOptions]
1183
+ * @returns {PropertyDecorator}
1184
+ */
1185
+ function Length(min, max, validationOptions) {
1186
+ return function (object, propertyName) {
1187
+ setExpose(object, propertyName);
1188
+ classValidator.registerDecorator({
1189
+ name: "vLength",
1190
+ target: object.constructor,
1191
+ propertyName,
1192
+ options: validationOptions,
1193
+ validator: {
1194
+ validate(value, args) {
1195
+ return classValidator.length(value, min, max);
1196
+ },
1197
+ defaultMessage(args) {
1198
+ return `invalid parameter ($property).`;
1199
+ }
1200
+ }
1201
+ });
1202
+ };
1203
+ }
1204
+ /**
1205
+ * Checks if the string is an email. If given value is not a string, then it returns false.
1206
+ *
1207
+ * @export
1208
+ * @param {IsEmailOptions} [options]
1209
+ * @param {ValidationOptions} [validationOptions]
1210
+ * @returns {PropertyDecorator}
1211
+ */
1212
+ function IsEmail(options, validationOptions) {
1213
+ return function (object, propertyName) {
1214
+ setExpose(object, propertyName);
1215
+ classValidator.registerDecorator({
1216
+ name: "vIsEmail",
1217
+ target: object.constructor,
1218
+ propertyName,
1219
+ options: validationOptions,
1220
+ validator: {
1221
+ validate(value, args) {
1222
+ return classValidator.isEmail(value);
1223
+ },
1224
+ defaultMessage(args) {
1225
+ return `invalid parameter ($property).`;
1226
+ }
1227
+ }
1228
+ });
1229
+ };
1230
+ }
1231
+ /**
1232
+ * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
1233
+ *
1234
+ * @export
1235
+ * @param {number} [version]
1236
+ * @param {ValidationOptions} [validationOptions]
1237
+ * @returns {PropertyDecorator}
1238
+ */
1239
+ function IsIP(version, validationOptions) {
1240
+ return function (object, propertyName) {
1241
+ setExpose(object, propertyName);
1242
+ classValidator.registerDecorator({
1243
+ name: "vIsIP",
1244
+ target: object.constructor,
1245
+ propertyName,
1246
+ options: validationOptions,
1247
+ validator: {
1248
+ validate(value, args) {
1249
+ return classValidator.isIP(value, version);
1250
+ },
1251
+ defaultMessage(args) {
1252
+ return `invalid parameter ($property).`;
1253
+ }
1254
+ }
1255
+ });
1256
+ };
1257
+ }
1258
+ /**
1259
+ * Checks if the string is a valid phone number.
1260
+ *
1261
+ * @export
1262
+ * @param {string} {string} region 2 characters uppercase country code (e.g. DE, US, CH).
1263
+ * If users must enter the intl. prefix (e.g. +41), then you may pass "ZZ" or null as region.
1264
+ * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
1265
+ * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
1266
+ * @param {ValidationOptions} [validationOptions]
1267
+ * @returns {PropertyDecorator}
1268
+ */
1269
+ function IsPhoneNumber(region, validationOptions) {
1270
+ return function (object, propertyName) {
1271
+ setExpose(object, propertyName);
1272
+ classValidator.registerDecorator({
1273
+ name: "vIsPhoneNumber",
1274
+ target: object.constructor,
1275
+ propertyName,
1276
+ options: validationOptions,
1277
+ validator: {
1278
+ validate(value, args) {
1279
+ return classValidator.isPhoneNumber(value, region);
1280
+ },
1281
+ defaultMessage(args) {
1282
+ return `invalid parameter ($property).`;
1283
+ }
1284
+ }
1285
+ });
1286
+ };
1287
+ }
1288
+ /**
1289
+ * Checks if the string is an url.
1290
+ *
1291
+ * @export
1292
+ * @param {IsURLOptions} [options]
1293
+ * @param {ValidationOptions} [validationOptions]
1294
+ * @returns {PropertyDecorator}
1295
+ */
1296
+ function IsUrl(options, validationOptions) {
1297
+ return function (object, propertyName) {
1298
+ setExpose(object, propertyName);
1299
+ classValidator.registerDecorator({
1300
+ name: "vIsUrl",
1301
+ target: object.constructor,
1302
+ propertyName,
1303
+ options: validationOptions,
1304
+ validator: {
1305
+ validate(value, args) {
1306
+ return classValidator.isURL(value, options);
1307
+ },
1308
+ defaultMessage(args) {
1309
+ return `invalid parameter ($property).`;
1310
+ }
1311
+ }
1312
+ });
1313
+ };
1314
+ }
1315
+ /**
1316
+ * check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256',
1317
+ * 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
1318
+ *
1319
+ * @export
1320
+ * @param {HashAlgorithm} algorithm
1321
+ * @param {ValidationOptions} [validationOptions]
1322
+ * @returns {PropertyDecorator}
1323
+ */
1324
+ function IsHash(algorithm, validationOptions) {
1325
+ return function (object, propertyName) {
1326
+ setExpose(object, propertyName);
1327
+ classValidator.registerDecorator({
1328
+ name: "vIsHash",
1329
+ target: object.constructor,
1330
+ propertyName,
1331
+ options: validationOptions,
1332
+ validator: {
1333
+ validate(value, args) {
1334
+ return classValidator.isHash(value, algorithm);
1335
+ },
1336
+ defaultMessage(args) {
1337
+ return `invalid parameter, ($property) must be is an ${algorithm} Hash string.`;
1338
+ }
1339
+ }
1340
+ });
1341
+ };
1342
+ }
1343
+
1344
+ exports.ClassValidator = ClassValidator;
1345
+ exports.Contains = Contains;
1346
+ exports.ENABLE_VALIDATED = ENABLE_VALIDATED;
1347
+ exports.Equals = Equals;
1348
+ exports.Expose = Expose;
1349
+ exports.FunctionValidator = FunctionValidator;
1350
+ exports.Gt = Gt;
1351
+ exports.Gte = Gte;
1352
+ exports.IsCnName = IsCnName;
1353
+ exports.IsDate = IsDate;
1354
+ exports.IsDefined = IsDefined;
1355
+ exports.IsEmail = IsEmail;
1356
+ exports.IsHash = IsHash;
1357
+ exports.IsIP = IsIP;
1358
+ exports.IsIdNumber = IsIdNumber;
1359
+ exports.IsIn = IsIn;
1360
+ exports.IsMobile = IsMobile;
1361
+ exports.IsNotEmpty = IsNotEmpty;
1362
+ exports.IsNotIn = IsNotIn;
1363
+ exports.IsPhoneNumber = IsPhoneNumber;
1364
+ exports.IsPlateNumber = IsPlateNumber;
1365
+ exports.IsUrl = IsUrl;
1366
+ exports.IsZipCode = IsZipCode;
1367
+ exports.Length = Length;
1368
+ exports.Lt = Lt;
1369
+ exports.Lte = Lte;
1370
+ exports.NotEquals = NotEquals;
1371
+ exports.PARAM_CHECK_KEY = PARAM_CHECK_KEY;
1372
+ exports.PARAM_RULE_KEY = PARAM_RULE_KEY;
1373
+ exports.PARAM_TYPE_KEY = PARAM_TYPE_KEY;
1374
+ exports.Valid = Valid;
1375
+ exports.Validated = Validated;
1376
+ exports.checkParamsType = checkParamsType;
1377
+ exports.convertDtoParamsType = convertDtoParamsType;
1378
+ exports.convertParamsType = convertParamsType;
1379
+ exports.plainToClass = plainToClass;