koatty_validation 1.0.12 → 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 +2 -6
- package/dist/LICENSE +29 -0
- package/dist/README.md +106 -0
- package/dist/index.d.ts +402 -9
- package/dist/index.js +1277 -21
- package/dist/index.mjs +1219 -0
- 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 +24 -20
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -43
- package/babel.config.js +0 -21
- package/commitlint.config.js +0 -14
- package/dist/decorator.d.ts +0 -237
- package/dist/decorator.js +0 -681
- package/dist/decorator.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/rule.d.ts +0 -83
- package/dist/rule.js +0 -291
- package/dist/rule.js.map +0 -1
- package/dist/util.d.ts +0 -108
- package/dist/util.js +0 -422
- 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/dist/rule.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export declare const PARAM_TYPE_KEY = "PARAM_TYPE_KEY";
|
|
2
|
-
export declare const PARAM_RULE_KEY = "PARAM_RULE_KEY";
|
|
3
|
-
export declare const PARAM_CHECK_KEY = "PARAM_CHECK_KEY";
|
|
4
|
-
export declare const ENABLE_VALIDATED = "ENABLE_VALIDATED";
|
|
5
|
-
/**
|
|
6
|
-
* paramterTypes
|
|
7
|
-
*
|
|
8
|
-
* @export
|
|
9
|
-
* @enum {number}
|
|
10
|
-
*/
|
|
11
|
-
export declare enum paramterTypes {
|
|
12
|
-
"Number" = 0,
|
|
13
|
-
"number" = 1,
|
|
14
|
-
"String" = 2,
|
|
15
|
-
"string" = 3,
|
|
16
|
-
"Boolean" = 4,
|
|
17
|
-
"boolean" = 5,
|
|
18
|
-
"Array" = 6,
|
|
19
|
-
"array" = 7,
|
|
20
|
-
"Tuple" = 8,
|
|
21
|
-
"tuple" = 9,
|
|
22
|
-
"Object" = 10,
|
|
23
|
-
"object" = 11,
|
|
24
|
-
"Enum" = 12,
|
|
25
|
-
"enum" = 13,
|
|
26
|
-
"Bigint" = 14,
|
|
27
|
-
"bigint" = 15,
|
|
28
|
-
"Null" = 16,
|
|
29
|
-
"null" = 17,
|
|
30
|
-
"Undefined" = 18,
|
|
31
|
-
"undefined" = 19
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* type checked rules
|
|
35
|
-
*
|
|
36
|
-
* @export
|
|
37
|
-
* @type {number}
|
|
38
|
-
*/
|
|
39
|
-
export declare type ValidRules = "IsNotEmpty" | "IsDate" | "IsEmail" | "IsIP" | "IsPhoneNumber" | "IsUrl" | "IsHash" | "IsCnName" | "IsIdNumber" | "IsZipCode" | "IsMobile" | "IsPlateNumber";
|
|
40
|
-
declare class ValidateClass {
|
|
41
|
-
private static instance;
|
|
42
|
-
private constructor();
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @static
|
|
47
|
-
* @returns
|
|
48
|
-
* @memberof ValidateUtil
|
|
49
|
-
*/
|
|
50
|
-
static getInstance(): ValidateClass;
|
|
51
|
-
/**
|
|
52
|
-
* validated data vs dto class
|
|
53
|
-
*
|
|
54
|
-
* @param {*} Clazz
|
|
55
|
-
* @param {*} data
|
|
56
|
-
* @param {boolean} [convert=false] auto convert parameters type
|
|
57
|
-
* @returns {Promise<any>}
|
|
58
|
-
* @memberof ValidateClass
|
|
59
|
-
*/
|
|
60
|
-
valid(Clazz: any, data: any, convert?: boolean): Promise<any>;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* ClassValidator for manual
|
|
64
|
-
*/
|
|
65
|
-
export declare const ClassValidator: ValidateClass;
|
|
66
|
-
/**
|
|
67
|
-
* Validator Functions
|
|
68
|
-
*/
|
|
69
|
-
export declare const FunctionValidator: any;
|
|
70
|
-
/**
|
|
71
|
-
* Use functions or built-in rules for validation.
|
|
72
|
-
*
|
|
73
|
-
* @export
|
|
74
|
-
* @param {string} name
|
|
75
|
-
* @param {*} value
|
|
76
|
-
* @param {string} type
|
|
77
|
-
* @param {(ValidRules | ValidRules[] | Function)} rule
|
|
78
|
-
* @param {string} [message]
|
|
79
|
-
* @param {boolean} [checkType=true]
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
export declare function ValidatorFuncs(name: string, value: any, type: string, rule: ValidRules | ValidRules[] | Function, message?: string, checkType?: boolean): any;
|
|
83
|
-
export {};
|
package/dist/rule.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidatorFuncs = exports.FunctionValidator = exports.ClassValidator = 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
|
-
* @Description:
|
|
7
|
-
* @Usage:
|
|
8
|
-
* @Author: richen
|
|
9
|
-
* @Date: 2021-11-25 10:47:04
|
|
10
|
-
* @LastEditTime: 2021-11-25 11:07:02
|
|
11
|
-
*/
|
|
12
|
-
const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
|
|
13
|
-
const util_1 = require("./util");
|
|
14
|
-
const class_validator_1 = require("class-validator");
|
|
15
|
-
// constant
|
|
16
|
-
exports.PARAM_TYPE_KEY = 'PARAM_TYPE_KEY';
|
|
17
|
-
exports.PARAM_RULE_KEY = 'PARAM_RULE_KEY';
|
|
18
|
-
exports.PARAM_CHECK_KEY = 'PARAM_CHECK_KEY';
|
|
19
|
-
exports.ENABLE_VALIDATED = "ENABLE_VALIDATED";
|
|
20
|
-
/**
|
|
21
|
-
* paramterTypes
|
|
22
|
-
*
|
|
23
|
-
* @export
|
|
24
|
-
* @enum {number}
|
|
25
|
-
*/
|
|
26
|
-
var paramterTypes;
|
|
27
|
-
(function (paramterTypes) {
|
|
28
|
-
paramterTypes[paramterTypes["Number"] = 0] = "Number";
|
|
29
|
-
paramterTypes[paramterTypes["number"] = 1] = "number";
|
|
30
|
-
paramterTypes[paramterTypes["String"] = 2] = "String";
|
|
31
|
-
paramterTypes[paramterTypes["string"] = 3] = "string";
|
|
32
|
-
paramterTypes[paramterTypes["Boolean"] = 4] = "Boolean";
|
|
33
|
-
paramterTypes[paramterTypes["boolean"] = 5] = "boolean";
|
|
34
|
-
paramterTypes[paramterTypes["Array"] = 6] = "Array";
|
|
35
|
-
paramterTypes[paramterTypes["array"] = 7] = "array";
|
|
36
|
-
paramterTypes[paramterTypes["Tuple"] = 8] = "Tuple";
|
|
37
|
-
paramterTypes[paramterTypes["tuple"] = 9] = "tuple";
|
|
38
|
-
paramterTypes[paramterTypes["Object"] = 10] = "Object";
|
|
39
|
-
paramterTypes[paramterTypes["object"] = 11] = "object";
|
|
40
|
-
paramterTypes[paramterTypes["Enum"] = 12] = "Enum";
|
|
41
|
-
paramterTypes[paramterTypes["enum"] = 13] = "enum";
|
|
42
|
-
paramterTypes[paramterTypes["Bigint"] = 14] = "Bigint";
|
|
43
|
-
paramterTypes[paramterTypes["bigint"] = 15] = "bigint";
|
|
44
|
-
paramterTypes[paramterTypes["Null"] = 16] = "Null";
|
|
45
|
-
paramterTypes[paramterTypes["null"] = 17] = "null";
|
|
46
|
-
paramterTypes[paramterTypes["Undefined"] = 18] = "Undefined";
|
|
47
|
-
paramterTypes[paramterTypes["undefined"] = 19] = "undefined";
|
|
48
|
-
})(paramterTypes = exports.paramterTypes || (exports.paramterTypes = {}));
|
|
49
|
-
class ValidateClass {
|
|
50
|
-
constructor() {
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @static
|
|
56
|
-
* @returns
|
|
57
|
-
* @memberof ValidateUtil
|
|
58
|
-
*/
|
|
59
|
-
static getInstance() {
|
|
60
|
-
return this.instance || (this.instance = new ValidateClass());
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* validated data vs dto class
|
|
64
|
-
*
|
|
65
|
-
* @param {*} Clazz
|
|
66
|
-
* @param {*} data
|
|
67
|
-
* @param {boolean} [convert=false] auto convert parameters type
|
|
68
|
-
* @returns {Promise<any>}
|
|
69
|
-
* @memberof ValidateClass
|
|
70
|
-
*/
|
|
71
|
-
async valid(Clazz, data, convert = false) {
|
|
72
|
-
let obj = {};
|
|
73
|
-
if (data instanceof Clazz) {
|
|
74
|
-
obj = data;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
obj = (0, util_1.plainToClass)(Clazz, data, convert);
|
|
78
|
-
}
|
|
79
|
-
let errors = [];
|
|
80
|
-
if (convert) {
|
|
81
|
-
errors = await (0, class_validator_1.validate)(obj);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
errors = await (0, class_validator_1.validate)(obj, { skipMissingProperties: true });
|
|
85
|
-
}
|
|
86
|
-
if (errors.length > 0) {
|
|
87
|
-
const err = new Error(Object.values(errors[0].constraints)[0]);
|
|
88
|
-
err.code = 400;
|
|
89
|
-
err.status = 400;
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
return obj;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* ClassValidator for manual
|
|
97
|
-
*/
|
|
98
|
-
exports.ClassValidator = ValidateClass.getInstance();
|
|
99
|
-
/**
|
|
100
|
-
* Validator Functions
|
|
101
|
-
*/
|
|
102
|
-
exports.FunctionValidator = {
|
|
103
|
-
/**
|
|
104
|
-
* Checks if value matches ("===") the comparison.
|
|
105
|
-
*/
|
|
106
|
-
Equals: (value, comparison) => {
|
|
107
|
-
return (0, class_validator_1.equals)(value, comparison);
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Checks if value does not match ("!==") the comparison.
|
|
111
|
-
*/
|
|
112
|
-
NotEquals: (value, comparison) => {
|
|
113
|
-
return (0, class_validator_1.notEquals)(value, comparison);
|
|
114
|
-
},
|
|
115
|
-
/**
|
|
116
|
-
* Checks if the string contains the seed. If given value is not a string, then it returns false.
|
|
117
|
-
*/
|
|
118
|
-
Contains: (value, seed) => {
|
|
119
|
-
return (0, class_validator_1.contains)(value, seed);
|
|
120
|
-
},
|
|
121
|
-
/**
|
|
122
|
-
* Checks if given value is in a array of allowed values.
|
|
123
|
-
*/
|
|
124
|
-
IsIn: (value, possibleValues) => {
|
|
125
|
-
return (0, class_validator_1.isIn)(value, possibleValues);
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* Checks if given value not in a array of allowed values.
|
|
129
|
-
*/
|
|
130
|
-
IsNotIn: (value, possibleValues) => {
|
|
131
|
-
return (0, class_validator_1.isNotIn)(value, possibleValues);
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* Checks if a given value is a real date.
|
|
135
|
-
*/
|
|
136
|
-
IsDate: (value) => {
|
|
137
|
-
return helper.isDate(value);
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* Checks if the first number is greater than or equal to the second.
|
|
141
|
-
*/
|
|
142
|
-
Min: (num, min) => {
|
|
143
|
-
return helper.toNumber(num) >= min;
|
|
144
|
-
},
|
|
145
|
-
/**
|
|
146
|
-
* Checks if the first number is less than or equal to the second.
|
|
147
|
-
*/
|
|
148
|
-
Max: (num, max) => {
|
|
149
|
-
return helper.toNumber(num) <= max;
|
|
150
|
-
},
|
|
151
|
-
/**
|
|
152
|
-
* Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
|
153
|
-
* If given value is not a string, then it returns false.
|
|
154
|
-
*/
|
|
155
|
-
Length: (value, min, max) => {
|
|
156
|
-
return (0, class_validator_1.length)(value, min, max);
|
|
157
|
-
},
|
|
158
|
-
/**
|
|
159
|
-
* Checks if the string is an email. If given value is not a string, then it returns false.
|
|
160
|
-
*/
|
|
161
|
-
IsEmail: (value, options) => {
|
|
162
|
-
return (0, class_validator_1.isEmail)(value, options);
|
|
163
|
-
},
|
|
164
|
-
/**
|
|
165
|
-
* Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
|
|
166
|
-
*/
|
|
167
|
-
IsIP: (value, version) => {
|
|
168
|
-
return (0, class_validator_1.isIP)(value, version);
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* Checks if the string is a valid phone number.
|
|
172
|
-
* @param value — the potential phone number string to test
|
|
173
|
-
* @param region 2 characters uppercase country code (e.g. DE, US, CH). If users must enter the intl.
|
|
174
|
-
* prefix (e.g. +41), then you may pass "ZZ" or null as region.
|
|
175
|
-
* See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
|
|
176
|
-
* {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
|
|
177
|
-
*/
|
|
178
|
-
IsPhoneNumber: (value, region) => {
|
|
179
|
-
return (0, class_validator_1.isPhoneNumber)(value, region);
|
|
180
|
-
},
|
|
181
|
-
/**
|
|
182
|
-
* Checks if the string is an url. If given value is not a string, then it returns false.
|
|
183
|
-
*/
|
|
184
|
-
IsUrl: (value, options) => {
|
|
185
|
-
return (0, class_validator_1.isURL)(value, options);
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* check if the string is a hash of type algorithm. Algorithm is one of
|
|
189
|
-
* ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
|
|
190
|
-
*/
|
|
191
|
-
IsHash: (value, algorithm) => {
|
|
192
|
-
return (0, class_validator_1.isHash)(value, algorithm);
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* Checks if value is a chinese name.
|
|
196
|
-
*/
|
|
197
|
-
IsCnName: (value) => {
|
|
198
|
-
if (!helper.isString(value)) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
return (0, util_1.cnName)(value);
|
|
202
|
-
},
|
|
203
|
-
/**
|
|
204
|
-
* Checks if value is a idcard number.
|
|
205
|
-
*/
|
|
206
|
-
IsIdNumber: (value) => {
|
|
207
|
-
if (!helper.isString(value)) {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
return (0, util_1.idNumber)(value);
|
|
211
|
-
},
|
|
212
|
-
/**
|
|
213
|
-
* Checks if value is a zipCode.
|
|
214
|
-
*/
|
|
215
|
-
IsZipCode: (value) => {
|
|
216
|
-
if (!helper.isString(value)) {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
return (0, util_1.zipCode)(value);
|
|
220
|
-
},
|
|
221
|
-
/**
|
|
222
|
-
* Checks if value is a mobile phone number.
|
|
223
|
-
*/
|
|
224
|
-
IsMobile: (value) => {
|
|
225
|
-
if (!helper.isString(value)) {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
return (0, util_1.mobile)(value);
|
|
229
|
-
},
|
|
230
|
-
/**
|
|
231
|
-
* Checks if value is a plateNumber.
|
|
232
|
-
*/
|
|
233
|
-
IsPlateNumber: (value) => {
|
|
234
|
-
if (!helper.isString(value)) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
return (0, util_1.plateNumber)(value);
|
|
238
|
-
},
|
|
239
|
-
/**
|
|
240
|
-
* Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces,
|
|
241
|
-
* tabs, formfeeds, etc.), returns false
|
|
242
|
-
*/
|
|
243
|
-
IsNotEmpty: (value) => {
|
|
244
|
-
return !helper.isEmpty(value);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* Use functions or built-in rules for validation.
|
|
249
|
-
*
|
|
250
|
-
* @export
|
|
251
|
-
* @param {string} name
|
|
252
|
-
* @param {*} value
|
|
253
|
-
* @param {string} type
|
|
254
|
-
* @param {(ValidRules | ValidRules[] | Function)} rule
|
|
255
|
-
* @param {string} [message]
|
|
256
|
-
* @param {boolean} [checkType=true]
|
|
257
|
-
* @returns
|
|
258
|
-
*/
|
|
259
|
-
function ValidatorFuncs(name, value, type, rule, message, checkType = true) {
|
|
260
|
-
// check type
|
|
261
|
-
if (checkType && !(0, util_1.checkParamsType)(value, type)) {
|
|
262
|
-
const err = new Error(`TypeError: invalid arguments '${name}'.`);
|
|
263
|
-
err.code = 400;
|
|
264
|
-
err.status = 400;
|
|
265
|
-
throw err;
|
|
266
|
-
}
|
|
267
|
-
if (helper.isFunction(rule)) {
|
|
268
|
-
if (!rule(value)) {
|
|
269
|
-
const err = new Error(message || `ValidatorError: invalid arguments[${name}].`);
|
|
270
|
-
err.code = 400;
|
|
271
|
-
err.status = 400;
|
|
272
|
-
throw err;
|
|
273
|
-
}
|
|
274
|
-
return value;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
const funcs = rule;
|
|
278
|
-
if (helper.isString(rule)) {
|
|
279
|
-
funcs.push(rule);
|
|
280
|
-
}
|
|
281
|
-
if (funcs.some((it) => exports.FunctionValidator[it] && !exports.FunctionValidator[it](value))) {
|
|
282
|
-
const err = new Error(message || `ValidatorError: invalid arguments[${name}].`);
|
|
283
|
-
err.code = 400;
|
|
284
|
-
err.status = 400;
|
|
285
|
-
throw err;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
exports.ValidatorFuncs = ValidatorFuncs;
|
|
291
|
-
//# sourceMappingURL=rule.js.map
|
package/dist/rule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,gEAAqC;AAGrC,iCAAuG;AACvG,qDAA6J;AAE7J,WAAW;AACE,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,cAAc,G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J;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAhCD,wCAgCC"}
|
package/dist/util.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ author: richen
|
|
3
|
-
* @ copyright: Copyright (c) - <richenlin(at)gmail.com>
|
|
4
|
-
* @ license: MIT
|
|
5
|
-
* @ version: 2020-03-20 11:34:38
|
|
6
|
-
*/
|
|
7
|
-
import "reflect-metadata";
|
|
8
|
-
/**
|
|
9
|
-
* Set property as included in the process of transformation.
|
|
10
|
-
*
|
|
11
|
-
* @export
|
|
12
|
-
* @param {Object} object
|
|
13
|
-
* @param {(string | symbol)} propertyName
|
|
14
|
-
*/
|
|
15
|
-
export declare function setExpose(object: Object, propertyName: string | symbol): void;
|
|
16
|
-
/**
|
|
17
|
-
* get metadata value of a metadata key on the prototype chain of an object and property
|
|
18
|
-
* @param metadataKey metadata key
|
|
19
|
-
* @param target the target of metadataKey
|
|
20
|
-
*/
|
|
21
|
-
export declare function recursiveGetMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): any[];
|
|
22
|
-
/**
|
|
23
|
-
* Dynamically add methods for target class types
|
|
24
|
-
*
|
|
25
|
-
* @param {Function} clazz
|
|
26
|
-
* @param {string} protoName
|
|
27
|
-
* @param {Function} func
|
|
28
|
-
*/
|
|
29
|
-
export declare function defineNewProperty(clazz: Function, protoName: string, func: Function): void;
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param {(string | symbol)} metadataKey
|
|
34
|
-
* @param {*} target
|
|
35
|
-
* @param {(string | symbol)} [propertyKey]
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
export declare function getOriginMetadata(metadataKey: string | symbol, target: any, propertyKey?: string | symbol): any;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @export
|
|
43
|
-
* @param {*} clazz
|
|
44
|
-
* @param {*} data
|
|
45
|
-
* @param {boolean} [convert=false]
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
export declare function plainToClass(clazz: any, data: any, convert?: boolean): any;
|
|
49
|
-
/**
|
|
50
|
-
* convertDtoParamsType
|
|
51
|
-
*
|
|
52
|
-
* @param {*} clazz
|
|
53
|
-
* @param {*} cls
|
|
54
|
-
* @param {*} data
|
|
55
|
-
* @returns {*}
|
|
56
|
-
*/
|
|
57
|
-
export declare function convertDtoParamsType(clazz: any, cls: any, data: any): any;
|
|
58
|
-
/**
|
|
59
|
-
* 绑定参数类型转换
|
|
60
|
-
*
|
|
61
|
-
* @param {*} param
|
|
62
|
-
* @param {string} type
|
|
63
|
-
* @returns {*}
|
|
64
|
-
*/
|
|
65
|
-
export declare function convertParamsType(param: any, type: string): any;
|
|
66
|
-
/**
|
|
67
|
-
* Check the base types.
|
|
68
|
-
*
|
|
69
|
-
* @param {*} value
|
|
70
|
-
* @param {string} type
|
|
71
|
-
* @returns {*}
|
|
72
|
-
*/
|
|
73
|
-
export declare function checkParamsType(value: any, type: string): any;
|
|
74
|
-
/**
|
|
75
|
-
* Checks if value is a chinese name.
|
|
76
|
-
*
|
|
77
|
-
* @param {string} value
|
|
78
|
-
* @returns {boolean}
|
|
79
|
-
*/
|
|
80
|
-
export declare function cnName(value: string): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Checks if value is a idCard number.
|
|
83
|
-
*
|
|
84
|
-
* @param {string} value
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
export declare function idNumber(value: string): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Checks if value is a mobile phone number.
|
|
90
|
-
*
|
|
91
|
-
* @param {string} value
|
|
92
|
-
* @returns {boolean}
|
|
93
|
-
*/
|
|
94
|
-
export declare function mobile(value: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Checks if value is a zipCode.
|
|
97
|
-
*
|
|
98
|
-
* @param {string} value
|
|
99
|
-
* @returns {boolean}
|
|
100
|
-
*/
|
|
101
|
-
export declare function zipCode(value: string): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Checks if value is a plateNumber.
|
|
104
|
-
*
|
|
105
|
-
* @param {string} value
|
|
106
|
-
* @returns {boolean}
|
|
107
|
-
*/
|
|
108
|
-
export declare function plateNumber(value: string): boolean;
|