koatty_validation 1.0.6 → 1.1.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/CHANGELOG.md +3 -1
- package/dist/LICENSE +29 -0
- package/dist/README.md +106 -0
- package/dist/index.d.ts +402 -19
- package/dist/index.js +1273 -94
- package/dist/{util.js → index.mjs} +1216 -887
- package/dist/package.json +90 -0
- package/jest-html-reporters-attach/index.js +58 -0
- package/jest-html-reporters-attach/result.js +1 -0
- package/package.json +28 -19
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -43
- package/babel.config.js +0 -21
- package/commitlint.config.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/lib.d.ts +0 -131
- package/dist/lib.js +0 -422
- package/dist/lib.js.map +0 -1
- package/dist/util.d.ts +0 -305
- package/dist/util.js.map +0 -1
- package/jest.config.js +0 -36
- package/jest_html_reporters.html +0 -60
- package/tsconfig.json +0 -67
- package/yarn-error.log +0 -5593
package/dist/lib.js
DELETED
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkParams = exports.plateNumber = exports.zipCode = exports.mobile = exports.idNumber = exports.cnName = exports.plainToClass = exports.checkParamsType = exports.convertParamsType = exports.getOriginMetadata = exports.defineNewProperty = exports.recursiveGetMetadata = exports.paramterTypes = exports.ENABLE_VALIDATED = exports.PARAM_CHECK_KEY = exports.PARAM_RULE_KEY = exports.PARAM_TYPE_KEY = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* @ author: richen
|
|
7
|
-
* @ copyright: Copyright (c) - <richenlin(at)gmail.com>
|
|
8
|
-
* @ license: MIT
|
|
9
|
-
* @ version: 2020-03-20 11:34:38
|
|
10
|
-
*/
|
|
11
|
-
// tslint:disable-next-line: no-import-side-effect
|
|
12
|
-
require("reflect-metadata");
|
|
13
|
-
const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
|
|
14
|
-
const koatty_logger_1 = require("koatty_logger");
|
|
15
|
-
const koatty_container_1 = require("koatty_container");
|
|
16
|
-
const util_1 = require("./util");
|
|
17
|
-
exports.PARAM_TYPE_KEY = 'PARAM_TYPE_KEY';
|
|
18
|
-
exports.PARAM_RULE_KEY = 'PARAM_RULE_KEY';
|
|
19
|
-
exports.PARAM_CHECK_KEY = 'PARAM_CHECK_KEY';
|
|
20
|
-
exports.ENABLE_VALIDATED = "ENABLE_VALIDATED";
|
|
21
|
-
var paramterTypes;
|
|
22
|
-
(function (paramterTypes) {
|
|
23
|
-
paramterTypes[paramterTypes["Number"] = 0] = "Number";
|
|
24
|
-
paramterTypes[paramterTypes["number"] = 1] = "number";
|
|
25
|
-
paramterTypes[paramterTypes["String"] = 2] = "String";
|
|
26
|
-
paramterTypes[paramterTypes["string"] = 3] = "string";
|
|
27
|
-
paramterTypes[paramterTypes["Boolean"] = 4] = "Boolean";
|
|
28
|
-
paramterTypes[paramterTypes["boolean"] = 5] = "boolean";
|
|
29
|
-
paramterTypes[paramterTypes["Array"] = 6] = "Array";
|
|
30
|
-
paramterTypes[paramterTypes["array"] = 7] = "array";
|
|
31
|
-
paramterTypes[paramterTypes["Tuple"] = 8] = "Tuple";
|
|
32
|
-
paramterTypes[paramterTypes["tuple"] = 9] = "tuple";
|
|
33
|
-
paramterTypes[paramterTypes["Object"] = 10] = "Object";
|
|
34
|
-
paramterTypes[paramterTypes["object"] = 11] = "object";
|
|
35
|
-
paramterTypes[paramterTypes["Enum"] = 12] = "Enum";
|
|
36
|
-
paramterTypes[paramterTypes["enum"] = 13] = "enum";
|
|
37
|
-
})(paramterTypes = exports.paramterTypes || (exports.paramterTypes = {}));
|
|
38
|
-
const functionPrototype = Object.getPrototypeOf(Function);
|
|
39
|
-
// get property of an object
|
|
40
|
-
// https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof
|
|
41
|
-
function ordinaryGetPrototypeOf(obj) {
|
|
42
|
-
const proto = Object.getPrototypeOf(obj);
|
|
43
|
-
if (typeof obj !== "function" || obj === functionPrototype) {
|
|
44
|
-
return proto;
|
|
45
|
-
}
|
|
46
|
-
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
|
47
|
-
// Try to determine the superclass constructor. Compatible implementations
|
|
48
|
-
// must either set __proto__ on a subclass constructor to the superclass constructor,
|
|
49
|
-
// or ensure each class has a valid `constructor` property on its prototype that
|
|
50
|
-
// points back to the constructor.
|
|
51
|
-
// If this is not the same as Function.[[Prototype]], then this is definitely inherited.
|
|
52
|
-
// This is the case when in ES6 or when using __proto__ in a compatible browser.
|
|
53
|
-
if (proto !== functionPrototype) {
|
|
54
|
-
return proto;
|
|
55
|
-
}
|
|
56
|
-
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
|
|
57
|
-
const prototype = obj.prototype;
|
|
58
|
-
const prototypeProto = prototype && Object.getPrototypeOf(prototype);
|
|
59
|
-
// tslint:disable-next-line: triple-equals
|
|
60
|
-
if (prototypeProto == undefined || prototypeProto === Object.prototype) {
|
|
61
|
-
return proto;
|
|
62
|
-
}
|
|
63
|
-
// If the constructor was not a function, then we cannot determine the heritage.
|
|
64
|
-
const constructor = prototypeProto.constructor;
|
|
65
|
-
if (typeof constructor !== "function") {
|
|
66
|
-
return proto;
|
|
67
|
-
}
|
|
68
|
-
// If we have some kind of self-reference, then we cannot determine the heritage.
|
|
69
|
-
if (constructor === obj) {
|
|
70
|
-
return proto;
|
|
71
|
-
}
|
|
72
|
-
// we have a pretty good guess at the heritage.
|
|
73
|
-
return constructor;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* get property metadata data
|
|
77
|
-
*
|
|
78
|
-
* @param {(string | symbol)} decoratorNameKey
|
|
79
|
-
* @param {*} target
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
function listPropertyData(decoratorNameKey, target, propertyKey) {
|
|
83
|
-
const originMap = getOriginMetadata(decoratorNameKey, target, propertyKey);
|
|
84
|
-
const data = {};
|
|
85
|
-
for (const [key, value] of originMap) {
|
|
86
|
-
data[key] = value;
|
|
87
|
-
}
|
|
88
|
-
return data;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* get metadata value of a metadata key on the prototype chain of an object and property
|
|
92
|
-
* @param metadataKey metadata key
|
|
93
|
-
* @param target the target of metadataKey
|
|
94
|
-
*/
|
|
95
|
-
function recursiveGetMetadata(metadataKey, target, propertyKey) {
|
|
96
|
-
// get metadata value of a metadata key on the prototype
|
|
97
|
-
// let metadata = Reflect.getOwnMetadata(metadataKey, target, propertyKey);
|
|
98
|
-
const metadata = listPropertyData(metadataKey, target, propertyKey) || {};
|
|
99
|
-
// get metadata value of a metadata key on the prototype chain
|
|
100
|
-
let parent = ordinaryGetPrototypeOf(target);
|
|
101
|
-
while (parent !== null) {
|
|
102
|
-
// metadata = Reflect.getOwnMetadata(metadataKey, parent, propertyKey);
|
|
103
|
-
const pMetadata = listPropertyData(metadataKey, parent, propertyKey);
|
|
104
|
-
if (pMetadata) {
|
|
105
|
-
for (const n in pMetadata) {
|
|
106
|
-
if (!metadata.hasOwnProperty(n)) {
|
|
107
|
-
metadata[n] = pMetadata[n];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
parent = ordinaryGetPrototypeOf(parent);
|
|
112
|
-
}
|
|
113
|
-
return metadata;
|
|
114
|
-
}
|
|
115
|
-
exports.recursiveGetMetadata = recursiveGetMetadata;
|
|
116
|
-
/**
|
|
117
|
-
* Dynamically add methods for target class types
|
|
118
|
-
*
|
|
119
|
-
* @param {Function} clazz
|
|
120
|
-
* @param {string} protoName
|
|
121
|
-
* @param {Function} func
|
|
122
|
-
*/
|
|
123
|
-
function defineNewProperty(clazz, protoName, func) {
|
|
124
|
-
const oldMethod = Reflect.get(clazz.prototype, protoName);
|
|
125
|
-
if (oldMethod) {
|
|
126
|
-
Reflect.defineProperty(clazz.prototype, protoName, {
|
|
127
|
-
writable: true,
|
|
128
|
-
value: function fn(...props) {
|
|
129
|
-
// process paramter
|
|
130
|
-
props = func(props);
|
|
131
|
-
// tslint:disable-next-line: no-invalid-this
|
|
132
|
-
return Reflect.apply(oldMethod, this, props);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.defineNewProperty = defineNewProperty;
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @param {(string | symbol)} metadataKey
|
|
142
|
-
* @param {*} target
|
|
143
|
-
* @param {(string | symbol)} [propertyKey]
|
|
144
|
-
* @returns
|
|
145
|
-
*/
|
|
146
|
-
function getOriginMetadata(metadataKey, target, propertyKey) {
|
|
147
|
-
// filter Object.create(null)
|
|
148
|
-
if (typeof target === "object" && target.constructor) {
|
|
149
|
-
target = target.constructor;
|
|
150
|
-
}
|
|
151
|
-
if (propertyKey) {
|
|
152
|
-
// for property or method
|
|
153
|
-
if (!Reflect.hasMetadata(metadataKey, target, propertyKey)) {
|
|
154
|
-
Reflect.defineMetadata(metadataKey, new Map(), target, propertyKey);
|
|
155
|
-
}
|
|
156
|
-
return Reflect.getMetadata(metadataKey, target, propertyKey);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
// for class
|
|
160
|
-
if (!Reflect.hasMetadata(metadataKey, target)) {
|
|
161
|
-
Reflect.defineMetadata(metadataKey, new Map(), target);
|
|
162
|
-
}
|
|
163
|
-
return Reflect.getMetadata(metadataKey, target);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exports.getOriginMetadata = getOriginMetadata;
|
|
167
|
-
/**
|
|
168
|
-
* Convert parameter's type to defined.
|
|
169
|
-
*
|
|
170
|
-
* @param {*} param
|
|
171
|
-
* @param {string} type
|
|
172
|
-
* @returns
|
|
173
|
-
*/
|
|
174
|
-
const convertParamsType = (param, type) => {
|
|
175
|
-
switch (type) {
|
|
176
|
-
case "Number":
|
|
177
|
-
case "number":
|
|
178
|
-
if (helper.isNaN(param)) {
|
|
179
|
-
return NaN;
|
|
180
|
-
}
|
|
181
|
-
if (helper.isNumberString(param)) {
|
|
182
|
-
return helper.toNumber(param);
|
|
183
|
-
}
|
|
184
|
-
if (helper.isNumber(param)) {
|
|
185
|
-
return param;
|
|
186
|
-
}
|
|
187
|
-
return NaN;
|
|
188
|
-
case "Boolean":
|
|
189
|
-
case "boolean":
|
|
190
|
-
return !!param;
|
|
191
|
-
case "Array":
|
|
192
|
-
case "array":
|
|
193
|
-
case "Tuple":
|
|
194
|
-
case "tuple":
|
|
195
|
-
if (helper.isArray(param)) {
|
|
196
|
-
return param;
|
|
197
|
-
}
|
|
198
|
-
return helper.toArray(param);
|
|
199
|
-
case "String":
|
|
200
|
-
case "string":
|
|
201
|
-
if (helper.isString(param)) {
|
|
202
|
-
return param;
|
|
203
|
-
}
|
|
204
|
-
return helper.toString(param);
|
|
205
|
-
// case "object":
|
|
206
|
-
// case "enum":
|
|
207
|
-
default: //any
|
|
208
|
-
return param;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
exports.convertParamsType = convertParamsType;
|
|
212
|
-
/**
|
|
213
|
-
* Check the base types.
|
|
214
|
-
*
|
|
215
|
-
* @param {*} value
|
|
216
|
-
* @param {string} type
|
|
217
|
-
* @returns {*}
|
|
218
|
-
*/
|
|
219
|
-
const checkParamsType = function (value, type) {
|
|
220
|
-
switch (type) {
|
|
221
|
-
case "Number":
|
|
222
|
-
case "number":
|
|
223
|
-
if (!helper.isNumber(value) || helper.isNaN(value)) {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
return true;
|
|
227
|
-
case "Boolean":
|
|
228
|
-
case "boolean":
|
|
229
|
-
if (!helper.isBoolean(value)) {
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
return true;
|
|
233
|
-
case "Array":
|
|
234
|
-
case "array":
|
|
235
|
-
case "Tuple":
|
|
236
|
-
if (!helper.isArray(value)) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
return true;
|
|
240
|
-
case "String":
|
|
241
|
-
case "string":
|
|
242
|
-
if (!helper.isString(value)) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
return true;
|
|
246
|
-
case "Object":
|
|
247
|
-
case "object":
|
|
248
|
-
case "Enum":
|
|
249
|
-
if (helper.isUndefined(value)) {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
return true;
|
|
253
|
-
default: //any
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
exports.checkParamsType = checkParamsType;
|
|
258
|
-
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* @export
|
|
262
|
-
* @param {*} clazz
|
|
263
|
-
* @param {*} data
|
|
264
|
-
* @param {boolean} [convert=false]
|
|
265
|
-
* @returns
|
|
266
|
-
*/
|
|
267
|
-
function plainToClass(clazz, data, convert = false) {
|
|
268
|
-
try {
|
|
269
|
-
if (helper.isClass(clazz)) {
|
|
270
|
-
let cls;
|
|
271
|
-
if (data instanceof clazz) {
|
|
272
|
-
cls = data;
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
if (!helper.isObject(data)) {
|
|
276
|
-
data = {};
|
|
277
|
-
}
|
|
278
|
-
cls = Reflect.construct(clazz, []);
|
|
279
|
-
}
|
|
280
|
-
const originMap = getOriginMetadata(exports.PARAM_TYPE_KEY, clazz);
|
|
281
|
-
for (const [key, value] of originMap) {
|
|
282
|
-
if (key && Object.prototype.hasOwnProperty.call(data, key)) {
|
|
283
|
-
if (convert) {
|
|
284
|
-
cls[key] = (0, exports.convertParamsType)(data[key], value);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
cls[key] = data[key];
|
|
288
|
-
if (!(0, exports.checkParamsType)(cls[key], value)) {
|
|
289
|
-
const err = new Error(`TypeError: invalid arguments '${key}'.`);
|
|
290
|
-
err.code = 400;
|
|
291
|
-
err.status = 400;
|
|
292
|
-
throw err;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return cls;
|
|
298
|
-
}
|
|
299
|
-
return data;
|
|
300
|
-
}
|
|
301
|
-
catch (err) {
|
|
302
|
-
koatty_logger_1.DefaultLogger.Error(err);
|
|
303
|
-
return data;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
exports.plainToClass = plainToClass;
|
|
307
|
-
/**
|
|
308
|
-
* Checks if value is a chinese name.
|
|
309
|
-
*
|
|
310
|
-
* @param {string} value
|
|
311
|
-
* @returns {boolean}
|
|
312
|
-
*/
|
|
313
|
-
function cnName(value) {
|
|
314
|
-
const reg = /^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/;
|
|
315
|
-
return reg.test(value);
|
|
316
|
-
}
|
|
317
|
-
exports.cnName = cnName;
|
|
318
|
-
/**
|
|
319
|
-
* Checks if value is a idCard number.
|
|
320
|
-
*
|
|
321
|
-
* @param {string} value
|
|
322
|
-
* @returns
|
|
323
|
-
*/
|
|
324
|
-
function idNumber(value) {
|
|
325
|
-
if (/^\d{15}$/.test(value)) {
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
if ((/^\d{17}[0-9X]$/).test(value)) {
|
|
329
|
-
const vs = '1,0,x,9,8,7,6,5,4,3,2'.split(',');
|
|
330
|
-
const ps = '7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2'.split(',');
|
|
331
|
-
const ss = value.toLowerCase().split('');
|
|
332
|
-
let r = 0;
|
|
333
|
-
for (let i = 0; i < 17; i++) {
|
|
334
|
-
r += ps[i] * ss[i];
|
|
335
|
-
}
|
|
336
|
-
const isOk = (vs[r % 11] === ss[17]);
|
|
337
|
-
return isOk;
|
|
338
|
-
}
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
exports.idNumber = idNumber;
|
|
342
|
-
/**
|
|
343
|
-
* Checks if value is a mobile phone number.
|
|
344
|
-
*
|
|
345
|
-
* @param {string} value
|
|
346
|
-
* @returns {boolean}
|
|
347
|
-
*/
|
|
348
|
-
function mobile(value) {
|
|
349
|
-
const reg = /^(13|14|15|16|17|18|19)\d{9}$/;
|
|
350
|
-
return reg.test(value);
|
|
351
|
-
}
|
|
352
|
-
exports.mobile = mobile;
|
|
353
|
-
/**
|
|
354
|
-
* Checks if value is a zipCode.
|
|
355
|
-
*
|
|
356
|
-
* @param {string} value
|
|
357
|
-
* @returns {boolean}
|
|
358
|
-
*/
|
|
359
|
-
function zipCode(value) {
|
|
360
|
-
const reg = /^\d{6}$/;
|
|
361
|
-
return reg.test(value);
|
|
362
|
-
}
|
|
363
|
-
exports.zipCode = zipCode;
|
|
364
|
-
/**
|
|
365
|
-
* Checks if value is a plateNumber.
|
|
366
|
-
*
|
|
367
|
-
* @param {string} value
|
|
368
|
-
* @returns {boolean}
|
|
369
|
-
*/
|
|
370
|
-
function plateNumber(value) {
|
|
371
|
-
// 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])$');
|
|
372
|
-
// let xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
|
|
373
|
-
const xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
|
|
374
|
-
// let cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
|
|
375
|
-
const cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
|
|
376
|
-
if (value.length === 7) {
|
|
377
|
-
return cReg.test(value);
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
//新能源车牌
|
|
381
|
-
return xReg.test(value);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
exports.plateNumber = plateNumber;
|
|
385
|
-
/**
|
|
386
|
-
* Check parameters against predefined rules
|
|
387
|
-
*
|
|
388
|
-
* @export
|
|
389
|
-
* @param {*} param
|
|
390
|
-
* @param {number} index
|
|
391
|
-
* @param {ParamOptions} [paramOptions={
|
|
392
|
-
* validRules: [],
|
|
393
|
-
* dtoCheck: false
|
|
394
|
-
* }]
|
|
395
|
-
*/
|
|
396
|
-
async function checkParams(value, paramOptions) {
|
|
397
|
-
if (paramOptions.isDto) {
|
|
398
|
-
// DTO class
|
|
399
|
-
const clazz = koatty_container_1.IOCContainer.getClass(paramOptions.type, "COMPONENT");
|
|
400
|
-
if (clazz) {
|
|
401
|
-
if (paramOptions.dtoCheck) {
|
|
402
|
-
value = await util_1.ClassValidator.valid(clazz, value, true);
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
value = plainToClass(clazz, value, true);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
value = (0, exports.convertParamsType)(value, paramOptions.type);
|
|
411
|
-
//@Valid()
|
|
412
|
-
if (paramOptions.validRules[paramOptions.index]) {
|
|
413
|
-
const { type, rule, message } = paramOptions.validRules[paramOptions.index];
|
|
414
|
-
if (type && rule) {
|
|
415
|
-
(0, util_1.ValidatorFuncs)(`${paramOptions.index}`, value, type, rule, message, false);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return value;
|
|
420
|
-
}
|
|
421
|
-
exports.checkParams = checkParams;
|
|
422
|
-
//# sourceMappingURL=lib.js.map
|
package/dist/lib.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":";;;;AAAA;;;;;GAKG;AACH,kDAAkD;AAClD,4BAA0B;AAC1B,gEAAqC;AACrC,iDAAwD;AACxD,uDAAgD;AAChD,iCAAwD;AAG3C,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD,IAAY,aAQX;AARD,WAAY,aAAa;IACrB,qDAAQ,CAAA;IAAE,qDAAQ,CAAA;IAClB,qDAAQ,CAAA;IAAE,qDAAQ,CAAA;IAClB,uDAAS,CAAA;IAAE,uDAAS,CAAA;IACpB,mDAAO,CAAA;IAAE,mDAAO,CAAA;IAChB,mDAAO,CAAA;IAAE,mDAAO,CAAA;IAChB,sDAAQ,CAAA;IAAE,sDAAQ,CAAA;IAClB,kDAAM,CAAA;IAAE,kDAAM,CAAA;AAClB,CAAC,EARW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAQxB;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC1D,4BAA4B;AAC5B,6DAA6D;AAC7D,SAAS,sBAAsB,CAAC,GAAQ;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,iBAAi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