koatty_validation 1.0.4 → 1.0.12

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/.eslintrc.js CHANGED
@@ -22,12 +22,13 @@ module.exports = {
22
22
  },
23
23
  rules: {
24
24
  "@typescript-eslint/no-explicit-any": "off",
25
- "@typescript-eslint/no-require-imports": "off",
25
+ // "@typescript-eslint/no-require-imports": "off",
26
26
  "@typescript-eslint/no-var-requires": "off",
27
27
  "@typescript-eslint/member-ordering": "off",
28
28
  "@typescript-eslint/consistent-type-assertions": "off",
29
29
  "@typescript-eslint/no-param-reassign": "off",
30
30
  "@typescript-eslint/no-empty-function": "off",
31
+ "@typescript-eslint/no-empty-interface": "off",
31
32
  "@typescript-eslint/explicit-module-boundary-types": "off",
32
33
  "@typescript-eslint/ban-types": ["error",
33
34
  {
package/CHANGELOG.md CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [1.0.4](https://github.com/koatty/koatty_validation/compare/v1.0.2...v1.0.4) (2021-07-12)
5
+ ### [1.0.12](https://github.com/koatty/koatty_validation/compare/v1.0.10...v1.0.12) (2021-12-21)
6
6
 
7
- ### [1.0.2](https://github.com/thinkkoa/koatty_validation/compare/v1.0.1...v1.0.2) (2021-06-28)
7
+ ### [1.0.10](https://github.com/koatty/koatty_validation/compare/v1.0.8...v1.0.10) (2021-11-25)
8
8
 
9
- ### 1.0.1 (2021-06-22)
9
+ ### [1.0.8](https://github.com/koatty/koatty_validation/compare/v1.0.6...v1.0.8) (2021-11-23)
10
+
11
+ ### [1.0.6](https://github.com/koatty/koatty_validation/compare/v1.0.4...v1.0.6) (2021-11-20)
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2020, ThinkKoa
3
+ Copyright (c) 2020, Koatty
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
package/babel.config.js CHANGED
@@ -1,11 +1,6 @@
1
1
  /*
2
2
  * @Description : babel配置
3
3
  * @usage : 用于jest执行用例
4
- * @Date : 2020-10-19 23:08:40
5
- * @Author : fankerwang<fankerwang@tencent.com>
6
- * @LastEditors : fankerwang<fankerwang@tencent.com>
7
- * @LastEditTime : 2021-05-21 20:27:11
8
- * @FilePath : /tkoatty/babel.config.js
9
4
  */
10
5
 
11
6
  module.exports = {
@@ -0,0 +1,237 @@
1
+ import { CountryCode } from 'libphonenumber-js';
2
+ import { ValidRules } from "./rule";
3
+ import { IsIpVersion, ValidationOptions } from "class-validator";
4
+ export interface IsEmailOptions {
5
+ allow_display_name?: boolean;
6
+ require_display_name?: boolean;
7
+ allow_utf8_local_part?: boolean;
8
+ require_tld?: boolean;
9
+ }
10
+ export interface IsURLOptions {
11
+ protocols?: string[];
12
+ require_tld?: boolean;
13
+ require_protocol?: boolean;
14
+ require_host?: boolean;
15
+ require_valid_protocol?: boolean;
16
+ allow_underscores?: boolean;
17
+ host_whitelist?: (string | RegExp)[];
18
+ host_blacklist?: (string | RegExp)[];
19
+ allow_trailing_dot?: boolean;
20
+ allow_protocol_relative_urls?: boolean;
21
+ disallow_auth?: boolean;
22
+ }
23
+ export declare type HashAlgorithm = "md4" | "md5" | "sha1" | "sha256" | "sha384" | "sha512" | "ripemd128" | "ripemd160" | "tiger128" | "tiger160" | "tiger192" | "crc32" | "crc32b";
24
+ /**
25
+ * Validation parameter's type and values.
26
+ *
27
+ * @export
28
+ * @param {(ValidRules | ValidRules[] | Function)} rule
29
+ * @param {string} [message]
30
+ * @returns {ParameterDecorator}
31
+ */
32
+ export declare function Valid(rule: ValidRules | ValidRules[] | Function, message?: string): ParameterDecorator;
33
+ /**
34
+ * Validation parameter's type and values from DTO class.
35
+ *
36
+ * @export
37
+ * @returns {MethodDecorator}
38
+ */
39
+ export declare function Validated(): MethodDecorator;
40
+ /**
41
+ * Marks property as included in the process of transformation.
42
+ *
43
+ * @export
44
+ * @returns {PropertyDecorator}
45
+ */
46
+ export declare function Expose(): PropertyDecorator;
47
+ /**
48
+ * Identifies that the field needs to be defined
49
+ *
50
+ * @export
51
+ * @returns {PropertyDecorator}
52
+ */
53
+ export declare function IsDefined(): PropertyDecorator;
54
+ /**
55
+ * Checks if value is a chinese name.
56
+ *
57
+ * @export
58
+ * @param {string} property
59
+ * @param {ValidationOptions} [validationOptions]
60
+ * @returns {PropertyDecorator}
61
+ */
62
+ export declare function IsCnName(validationOptions?: ValidationOptions): PropertyDecorator;
63
+ /**
64
+ * Checks if value is a idCard number(chinese).
65
+ *
66
+ * @export
67
+ * @param {string} property
68
+ * @param {ValidationOptions} [validationOptions]
69
+ * @returns {PropertyDecorator}
70
+ */
71
+ export declare function IsIdNumber(validationOptions?: ValidationOptions): PropertyDecorator;
72
+ /**
73
+ * Checks if value is a zipCode(chinese).
74
+ *
75
+ * @export
76
+ * @param {string} property
77
+ * @param {ValidationOptions} [validationOptions]
78
+ * @returns {PropertyDecorator}
79
+ */
80
+ export declare function IsZipCode(validationOptions?: ValidationOptions): PropertyDecorator;
81
+ /**
82
+ * Checks if value is a mobile phone number(chinese).
83
+ *
84
+ * @export
85
+ * @param {string} property
86
+ * @param {ValidationOptions} [validationOptions]
87
+ * @returns {PropertyDecorator}
88
+ */
89
+ export declare function IsMobile(validationOptions?: ValidationOptions): PropertyDecorator;
90
+ /**
91
+ * Checks if value is a plate number(chinese).
92
+ *
93
+ * @export
94
+ * @param {string} property
95
+ * @param {ValidationOptions} [validationOptions]
96
+ * @returns {PropertyDecorator}
97
+ */
98
+ export declare function IsPlateNumber(validationOptions?: ValidationOptions): PropertyDecorator;
99
+ /**
100
+ * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces, tabs, formfeeds, etc.), returns false.
101
+ *
102
+ * @export
103
+ * @param {ValidationOptions} [validationOptions]
104
+ * @returns {PropertyDecorator}
105
+ */
106
+ export declare function IsNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator;
107
+ /**
108
+ * Checks if value matches ("===") the comparison.
109
+ *
110
+ * @export
111
+ * @param {*} comparison
112
+ * @param {ValidationOptions} [validationOptions]
113
+ * @returns {PropertyDecorator}
114
+ */
115
+ export declare function Equals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator;
116
+ /**
117
+ * Checks if value does not match ("!==") the comparison.
118
+ *
119
+ * @export
120
+ * @param {*} comparison
121
+ * @param {ValidationOptions} [validationOptions]
122
+ * @returns {PropertyDecorator}
123
+ */
124
+ export declare function NotEquals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator;
125
+ /**
126
+ * Checks if the string contains the seed.
127
+ *
128
+ * @export
129
+ * @param {string} seed
130
+ * @param {ValidationOptions} [validationOptions]
131
+ * @returns {PropertyDecorator}
132
+ */
133
+ export declare function Contains(seed: string, validationOptions?: ValidationOptions): PropertyDecorator;
134
+ /**
135
+ * Checks if given value is in a array of allowed values.
136
+ *
137
+ * @export
138
+ * @param {any[]} possibleValues
139
+ * @param {ValidationOptions} [validationOptions]
140
+ * @returns {PropertyDecorator}
141
+ */
142
+ export declare function IsIn(possibleValues: any[], validationOptions?: ValidationOptions): PropertyDecorator;
143
+ /**
144
+ * Checks if given value not in a array of allowed values.
145
+ *
146
+ * @export
147
+ * @param {any[]} possibleValues
148
+ * @param {ValidationOptions} [validationOptions]
149
+ * @returns {PropertyDecorator}
150
+ */
151
+ export declare function IsNotIn(possibleValues: any[], validationOptions?: ValidationOptions): PropertyDecorator;
152
+ /**
153
+ * Checks if a given value is a real date.
154
+ *
155
+ * @export
156
+ * @param {ValidationOptions} [validationOptions]
157
+ * @returns {PropertyDecorator}
158
+ */
159
+ export declare function IsDate(validationOptions?: ValidationOptions): PropertyDecorator;
160
+ /**
161
+ * Checks if the first number is greater than or equal to the min value.
162
+ *
163
+ * @export
164
+ * @param {number} min
165
+ * @param {ValidationOptions} [validationOptions]
166
+ * @returns {PropertyDecorator}
167
+ */
168
+ export declare function Min(min: number, validationOptions?: ValidationOptions): PropertyDecorator;
169
+ /**
170
+ * Checks if the first number is less than or equal to the max value.
171
+ *
172
+ * @export
173
+ * @param {number} max
174
+ * @param {ValidationOptions} [validationOptions]
175
+ * @returns {PropertyDecorator}
176
+ */
177
+ export declare function Max(max: number, validationOptions?: ValidationOptions): PropertyDecorator;
178
+ /**
179
+ * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
180
+ * If given value is not a string, then it returns false.
181
+ *
182
+ * @export
183
+ * @param {number} min
184
+ * @param {number} [max]
185
+ * @param {ValidationOptions} [validationOptions]
186
+ * @returns {PropertyDecorator}
187
+ */
188
+ export declare function Length(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator;
189
+ /**
190
+ * Checks if the string is an email. If given value is not a string, then it returns false.
191
+ *
192
+ * @export
193
+ * @param {IsEmailOptions} [options]
194
+ * @param {ValidationOptions} [validationOptions]
195
+ * @returns {PropertyDecorator}
196
+ */
197
+ export declare function IsEmail(options?: IsEmailOptions, validationOptions?: ValidationOptions): PropertyDecorator;
198
+ /**
199
+ * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
200
+ *
201
+ * @export
202
+ * @param {number} [version]
203
+ * @param {ValidationOptions} [validationOptions]
204
+ * @returns {PropertyDecorator}
205
+ */
206
+ export declare function IsIP(version?: IsIpVersion, validationOptions?: ValidationOptions): PropertyDecorator;
207
+ /**
208
+ * Checks if the string is a valid phone number.
209
+ *
210
+ * @export
211
+ * @param {string} {string} region 2 characters uppercase country code (e.g. DE, US, CH).
212
+ * If users must enter the intl. prefix (e.g. +41), then you may pass "ZZ" or null as region.
213
+ * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
214
+ * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
215
+ * @param {ValidationOptions} [validationOptions]
216
+ * @returns {PropertyDecorator}
217
+ */
218
+ export declare function IsPhoneNumber(region?: CountryCode, validationOptions?: ValidationOptions): PropertyDecorator;
219
+ /**
220
+ * Checks if the string is an url.
221
+ *
222
+ * @export
223
+ * @param {IsURLOptions} [options]
224
+ * @param {ValidationOptions} [validationOptions]
225
+ * @returns {PropertyDecorator}
226
+ */
227
+ export declare function IsUrl(options?: IsURLOptions, validationOptions?: ValidationOptions): PropertyDecorator;
228
+ /**
229
+ * check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256',
230
+ * 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
231
+ *
232
+ * @export
233
+ * @param {HashAlgorithm} algorithm
234
+ * @param {ValidationOptions} [validationOptions]
235
+ * @returns {PropertyDecorator}
236
+ */
237
+ export declare function IsHash(algorithm: HashAlgorithm, validationOptions?: ValidationOptions): PropertyDecorator;