valgen 5.3.0 → 5.3.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/CHANGELOG.md +17 -0
- package/cjs/core/context.js +2 -3
- package/cjs/core/validator.js +4 -4
- package/cjs/index.js +5 -5
- package/cjs/rules/format-rules/is-alpha.js +52 -0
- package/cjs/rules/format-rules/is-ascii.js +40 -0
- package/cjs/rules/format-rules/is-base64.js +40 -0
- package/cjs/rules/format-rules/is-btc-address.js +40 -0
- package/cjs/rules/format-rules/is-credit-card.js +40 -0
- package/cjs/rules/format-rules/is-decimal.js +41 -0
- package/cjs/rules/format-rules/is-ean.js +40 -0
- package/cjs/rules/format-rules/is-email.js +97 -0
- package/cjs/rules/format-rules/is-eth-address.js +40 -0
- package/cjs/rules/format-rules/is-fqdn.js +44 -0
- package/cjs/rules/format-rules/is-hash.js +40 -0
- package/cjs/rules/format-rules/is-hex-color.js +40 -0
- package/cjs/rules/format-rules/is-hex.js +40 -0
- package/cjs/rules/format-rules/is-iban.js +52 -0
- package/cjs/rules/format-rules/is-ip.js +52 -0
- package/cjs/rules/format-rules/is-issn.js +44 -0
- package/cjs/rules/format-rules/is-jwt.js +40 -0
- package/cjs/rules/format-rules/is-lowercase.js +52 -0
- package/cjs/rules/format-rules/is-mac-address.js +45 -0
- package/cjs/rules/format-rules/is-mobile-phone.js +43 -0
- package/cjs/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/cjs/rules/format-rules/is-passport-number.js +40 -0
- package/cjs/rules/format-rules/is-port.js +40 -0
- package/cjs/rules/format-rules/is-url.js +40 -0
- package/cjs/rules/format-rules/is-uuid.js +40 -0
- package/cjs/rules/format-rules/is-vat-number.js +40 -0
- package/cjs/rules/{is-regexp.js → format-rules/matches.js} +8 -5
- package/cjs/rules/index.js +49 -22
- package/cjs/rules/logical-rules/is-defined.js +30 -0
- package/cjs/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/cjs/rules/{range.js → logical-rules/range.js} +63 -38
- package/cjs/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/cjs/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/cjs/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/cjs/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/cjs/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/cjs/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/cjs/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/cjs/rules/{is-null.js → type-rules/is-null.js} +2 -28
- package/cjs/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/cjs/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/cjs/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/cjs/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/cjs/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/cjs/rules/utility-rules/exists.js +16 -0
- package/cjs/rules/utility-rules/get-length.js +24 -0
- package/cjs/rules/utility-rules/optional.js +16 -0
- package/cjs/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/cjs/rules/utility-rules/required.js +18 -0
- package/cjs/rules/{union.js → utility-rules/union.js} +2 -2
- package/esm/core/context.js +2 -3
- package/esm/core/validator.js +4 -4
- package/esm/index.js +3 -3
- package/esm/rules/format-rules/is-alpha.js +24 -0
- package/esm/rules/format-rules/is-ascii.js +13 -0
- package/esm/rules/format-rules/is-base64.js +13 -0
- package/esm/rules/format-rules/is-btc-address.js +13 -0
- package/esm/rules/format-rules/is-credit-card.js +13 -0
- package/esm/rules/format-rules/is-decimal.js +14 -0
- package/esm/rules/format-rules/is-ean.js +13 -0
- package/esm/rules/format-rules/is-email.js +70 -0
- package/esm/rules/format-rules/is-eth-address.js +13 -0
- package/esm/rules/format-rules/is-fqdn.js +17 -0
- package/esm/rules/format-rules/is-hash.js +13 -0
- package/esm/rules/format-rules/is-hex-color.js +13 -0
- package/esm/rules/format-rules/is-hex.js +13 -0
- package/esm/rules/format-rules/is-iban.js +24 -0
- package/esm/rules/format-rules/is-ip.js +24 -0
- package/esm/rules/format-rules/is-issn.js +17 -0
- package/esm/rules/format-rules/is-jwt.js +13 -0
- package/esm/rules/format-rules/is-lowercase.js +24 -0
- package/esm/rules/format-rules/is-mac-address.js +18 -0
- package/esm/rules/format-rules/is-mobile-phone.js +16 -0
- package/esm/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/esm/rules/format-rules/is-passport-number.js +13 -0
- package/esm/rules/format-rules/is-port.js +13 -0
- package/esm/rules/format-rules/is-url.js +13 -0
- package/esm/rules/format-rules/is-uuid.js +13 -0
- package/esm/rules/format-rules/is-vat-number.js +13 -0
- package/esm/rules/{is-regexp.js → format-rules/matches.js} +6 -3
- package/esm/rules/index.js +49 -22
- package/esm/rules/logical-rules/is-defined.js +25 -0
- package/esm/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/esm/rules/{range.js → logical-rules/range.js} +59 -36
- package/esm/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/esm/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/esm/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/esm/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/esm/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/esm/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/esm/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/esm/rules/{is-null.js → type-rules/is-null.js} +1 -25
- package/esm/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/esm/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/esm/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/esm/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/esm/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/esm/rules/utility-rules/exists.js +12 -0
- package/esm/rules/utility-rules/get-length.js +20 -0
- package/esm/rules/utility-rules/optional.js +12 -0
- package/esm/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/esm/rules/utility-rules/required.js +14 -0
- package/esm/rules/{union.js → utility-rules/union.js} +2 -2
- package/package.json +3 -3
- package/typings/index.d.ts +4 -4
- package/typings/rules/format-rules/is-alpha.d.ts +11 -0
- package/typings/rules/format-rules/is-ascii.d.ts +6 -0
- package/typings/rules/format-rules/is-base64.d.ts +9 -0
- package/typings/rules/format-rules/is-btc-address.d.ts +6 -0
- package/typings/rules/format-rules/is-credit-card.d.ts +9 -0
- package/typings/rules/format-rules/is-decimal.d.ts +7 -0
- package/typings/rules/format-rules/is-ean.d.ts +6 -0
- package/typings/rules/format-rules/is-email.d.ts +62 -0
- package/typings/rules/format-rules/is-eth-address.d.ts +6 -0
- package/typings/rules/format-rules/is-fqdn.d.ts +13 -0
- package/typings/rules/format-rules/is-hash.d.ts +8 -0
- package/typings/rules/format-rules/is-hex-color.d.ts +6 -0
- package/typings/rules/format-rules/is-hex.d.ts +6 -0
- package/typings/rules/format-rules/is-iban.d.ts +11 -0
- package/typings/rules/format-rules/is-ip.d.ts +11 -0
- package/typings/rules/format-rules/is-issn.d.ts +14 -0
- package/typings/rules/format-rules/is-jwt.d.ts +6 -0
- package/typings/rules/format-rules/is-lowercase.d.ts +11 -0
- package/typings/rules/format-rules/is-mac-address.d.ts +21 -0
- package/typings/rules/format-rules/is-mobile-phone.d.ts +20 -0
- package/typings/rules/{is-object-id.d.ts → format-rules/is-object-id.d.ts} +2 -2
- package/typings/rules/format-rules/is-passport-number.d.ts +6 -0
- package/typings/rules/format-rules/is-port.d.ts +6 -0
- package/typings/rules/format-rules/is-url.d.ts +9 -0
- package/typings/rules/format-rules/is-uuid.d.ts +6 -0
- package/typings/rules/format-rules/is-vat-number.d.ts +6 -0
- package/typings/rules/format-rules/matches.d.ts +9 -0
- package/typings/rules/index.d.ts +49 -22
- package/typings/rules/logical-rules/is-defined.d.ts +11 -0
- package/typings/rules/{is-empty.d.ts → logical-rules/is-empty.d.ts} +3 -3
- package/typings/rules/{range.d.ts → logical-rules/range.d.ts} +14 -4
- package/typings/rules/type-rules/is-any.d.ts +5 -0
- package/typings/rules/{is-array.d.ts → type-rules/is-array.d.ts} +2 -2
- package/typings/rules/{is-bigint.d.ts → type-rules/is-bigint.d.ts} +2 -2
- package/typings/rules/{is-boolean.d.ts → type-rules/is-boolean.d.ts} +2 -2
- package/typings/rules/{is-date.d.ts → type-rules/is-date.d.ts} +3 -3
- package/typings/rules/{is-enum.d.ts → type-rules/is-enum.d.ts} +1 -1
- package/typings/rules/{is-integer.d.ts → type-rules/is-integer.d.ts} +2 -2
- package/typings/rules/type-rules/is-null.d.ts +11 -0
- package/typings/rules/{is-number.d.ts → type-rules/is-number.d.ts} +2 -2
- package/typings/rules/{is-object.d.ts → type-rules/is-object.d.ts} +1 -1
- package/typings/rules/{is-record.d.ts → type-rules/is-record.d.ts} +2 -2
- package/typings/rules/{is-string.d.ts → type-rules/is-string.d.ts} +5 -5
- package/typings/rules/{is-tuple.d.ts → type-rules/is-tuple.d.ts} +2 -8
- package/typings/rules/utility-rules/exists.d.ts +6 -0
- package/typings/rules/utility-rules/get-length.d.ts +11 -0
- package/typings/rules/utility-rules/optional.d.ts +7 -0
- package/typings/rules/{pipe.d.ts → utility-rules/pipe.d.ts} +1 -1
- package/typings/rules/utility-rules/required.d.ts +7 -0
- package/typings/rules/utility-rules/union.d.ts +5 -0
- package/cjs/rules/length.js +0 -41
- package/cjs/rules/optional.js +0 -44
- package/cjs/rules/string-formats.js +0 -377
- package/esm/rules/length.js +0 -35
- package/esm/rules/optional.js +0 -38
- package/esm/rules/string-formats.js +0 -322
- package/typings/rules/is-any.d.ts +0 -5
- package/typings/rules/is-null.d.ts +0 -21
- package/typings/rules/is-regexp.d.ts +0 -9
- package/typings/rules/length.d.ts +0 -21
- package/typings/rules/optional.d.ts +0 -17
- package/typings/rules/string-formats.d.ts +0 -166
- package/typings/rules/union.d.ts +0 -5
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import * as validatorJS from 'validator';
|
|
2
|
-
import { validator } from '../core/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Validates if value is an "UUID".
|
|
5
|
-
* @validator isUUID
|
|
6
|
-
*/
|
|
7
|
-
export function isUUID(version, options) {
|
|
8
|
-
return validator('isUUID', function (input, context, _this) {
|
|
9
|
-
if (input != null && typeof input === 'string' && validatorJS.isUUID(input, version))
|
|
10
|
-
return input;
|
|
11
|
-
context.fail(_this, `{{label}} is not a valid UUID${version ? ' v' + version : ''}`, input);
|
|
12
|
-
}, options);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Validates if value is a valid Email
|
|
16
|
-
* @validator isEmail
|
|
17
|
-
*/
|
|
18
|
-
export function isEmail(options) {
|
|
19
|
-
return validator('isEmail', function (input, context, _this) {
|
|
20
|
-
if (typeof input === 'string' && validatorJS.isEmail(input, options))
|
|
21
|
-
return input;
|
|
22
|
-
context.fail(_this, `{{label}} is not a valid a EMail`, input);
|
|
23
|
-
}, options);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Validates if value is a valid Email
|
|
27
|
-
* @validator isMobilePhone
|
|
28
|
-
*/
|
|
29
|
-
export function isMobilePhone(options) {
|
|
30
|
-
return validator('isMobilePhone', function (input, context, _this) {
|
|
31
|
-
if (typeof input === 'string' && validatorJS.isMobilePhone(input, options?.locale, options))
|
|
32
|
-
return input;
|
|
33
|
-
context.fail(_this, `{{label}} is not a valid a Mobile Phone Number`, input);
|
|
34
|
-
}, options);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Validates if value is an IP
|
|
38
|
-
* @validator isIP
|
|
39
|
-
*/
|
|
40
|
-
export function isIP(version, options) {
|
|
41
|
-
return validator('isIP', function (input, context, _this) {
|
|
42
|
-
if (input != null && typeof input === 'string' && validatorJS.isIP(input, version))
|
|
43
|
-
return input;
|
|
44
|
-
context.fail(_this, `{{label}} is not a valid IP${version ? ' v' + version : ''}`, input);
|
|
45
|
-
}, options);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Validates if value is an IP
|
|
49
|
-
* @validator isUUID
|
|
50
|
-
*/
|
|
51
|
-
export function isIPRange(version, options) {
|
|
52
|
-
return validator('isIPRange', function (input, context, _this) {
|
|
53
|
-
if (input != null && typeof input === 'string' && validatorJS.isIPRange(input, version))
|
|
54
|
-
return input;
|
|
55
|
-
context.fail(_this, `{{label}} is not a valid IP${version ? ' v' + version : ''} range`, input);
|
|
56
|
-
}, options);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Validates if value is an MACAddress
|
|
60
|
-
* @validator isMACAddress
|
|
61
|
-
*/
|
|
62
|
-
export function isMACAddress(options) {
|
|
63
|
-
return validator('isMACAddress', function (input, context, _this) {
|
|
64
|
-
if (input != null && typeof input === 'string' && validatorJS.isMACAddress(input, options))
|
|
65
|
-
return input;
|
|
66
|
-
context.fail(_this, `{{label}} is not a valid MAC address`, input);
|
|
67
|
-
}, options);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Validates if value is a port number
|
|
71
|
-
* @validator isPort
|
|
72
|
-
*/
|
|
73
|
-
export function isPort(options) {
|
|
74
|
-
return validator('isPort', function (input, context, _this) {
|
|
75
|
-
if (input != null && typeof input === 'string' && validatorJS.isPort(input))
|
|
76
|
-
return input;
|
|
77
|
-
context.fail(_this, `{{label}} is not a valid port number`, input);
|
|
78
|
-
}, options);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Validates if value is an MACAddress
|
|
82
|
-
* @validator isURL
|
|
83
|
-
*/
|
|
84
|
-
export function isURL(options) {
|
|
85
|
-
return validator('isURL', function (input, context, _this) {
|
|
86
|
-
if (input != null && typeof input === 'string' && validatorJS.isURL(input, options))
|
|
87
|
-
return input;
|
|
88
|
-
context.fail(_this, `{{label}} is not a valid URL`, input);
|
|
89
|
-
}, options);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Validates if value is a "Base64" string.
|
|
93
|
-
* @validator isBase64
|
|
94
|
-
*/
|
|
95
|
-
export function isBase64(options) {
|
|
96
|
-
return validator('isBase64', function (input, context, _this) {
|
|
97
|
-
if (typeof input === 'string' && validatorJS.isBase64(input, options))
|
|
98
|
-
return input;
|
|
99
|
-
context.fail(_this, `{{label}} is not a valid a Base64 string`, input);
|
|
100
|
-
}, options);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
104
|
-
* @validator isBIC
|
|
105
|
-
*/
|
|
106
|
-
export function isBIC(options) {
|
|
107
|
-
return validator('isBIC', function (input, context, _this) {
|
|
108
|
-
if (typeof input === 'string' && validatorJS.isBIC(input))
|
|
109
|
-
return input;
|
|
110
|
-
context.fail(_this, `{{label}}is not a valid a BIC (Bank Identification Code) or SWIFT code`, input);
|
|
111
|
-
}, options);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Validates if value is a "Base64" formatted string.
|
|
115
|
-
* @validator isCreditCard
|
|
116
|
-
*/
|
|
117
|
-
export function isCreditCard(options) {
|
|
118
|
-
return validator('isCreditCard', function (input, context, _this) {
|
|
119
|
-
if (typeof input === 'string' && validatorJS.isCreditCard(input, options))
|
|
120
|
-
return input;
|
|
121
|
-
context.fail(_this, `{{label}} is not a valid Credit Card number`, input);
|
|
122
|
-
}, options);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validates if value is an IBAN (International Bank Account Number)
|
|
126
|
-
* @validator isEAN
|
|
127
|
-
*/
|
|
128
|
-
export function isIBAN(options) {
|
|
129
|
-
return validator('isIBAN', function (input, context, _this) {
|
|
130
|
-
if (typeof input === 'string' && validatorJS.isIBAN(input))
|
|
131
|
-
return input;
|
|
132
|
-
context.fail(_this, `{{label}} is not a valid IBAN (International Bank Account Number)`, input);
|
|
133
|
-
}, options);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Validates if value is an passport number
|
|
137
|
-
* @validator isPassportNumber
|
|
138
|
-
*/
|
|
139
|
-
export function isPassportNumber(countryCode, options) {
|
|
140
|
-
return validator('isPassportNumber', function (input, context, _this) {
|
|
141
|
-
if (typeof input === 'string' && validatorJS.isPassportNumber(input, countryCode))
|
|
142
|
-
return input;
|
|
143
|
-
context.fail(_this, `{{label}} is not a valid ${countryCode} PassportNumber)`, input);
|
|
144
|
-
}, options);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Validates if value is an EAN (European Article Number)
|
|
148
|
-
* @validator isEAN
|
|
149
|
-
*/
|
|
150
|
-
export function isEAN(options) {
|
|
151
|
-
return validator('isEAN', function (input, context, _this) {
|
|
152
|
-
if (typeof input === 'string' && validatorJS.isEAN(input))
|
|
153
|
-
return input;
|
|
154
|
-
context.fail(_this, `{{label}} is not a valid EAN (European Article Number)`, input);
|
|
155
|
-
}, options);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Validates if value is an FQDN
|
|
159
|
-
* @validator isFQDN
|
|
160
|
-
*/
|
|
161
|
-
export function isFQDN(options) {
|
|
162
|
-
return validator('isFQDN', function (input, context, _this) {
|
|
163
|
-
if (typeof input === 'string' && validatorJS.isFQDN(input, options))
|
|
164
|
-
return input;
|
|
165
|
-
context.fail(_this, `{{label}} is not valid FQDN`, input);
|
|
166
|
-
}, options);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Validates if value is an ISSN
|
|
170
|
-
* @validator isISSN
|
|
171
|
-
*/
|
|
172
|
-
export function isISSN(options) {
|
|
173
|
-
return validator('isISSN', function (input, context, _this) {
|
|
174
|
-
if (typeof input === 'string' && validatorJS.isISSN(input, options))
|
|
175
|
-
return input;
|
|
176
|
-
context.fail(_this, `{{label}} is not a valid ISSN`, input);
|
|
177
|
-
}, options);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Validates if value is an VAT number
|
|
181
|
-
* @validator isVAT
|
|
182
|
-
*/
|
|
183
|
-
export function isVAT(countryCode, options) {
|
|
184
|
-
return validator('isVAT', function (input, context, _this) {
|
|
185
|
-
if (typeof input === 'string' && validatorJS.isVAT(input, countryCode))
|
|
186
|
-
return input;
|
|
187
|
-
context.fail(_this, `{{label}} is not a valid VAT number`, input);
|
|
188
|
-
}, options);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Validates if value is a BTC address.
|
|
192
|
-
* @validator isBtcAddress
|
|
193
|
-
*/
|
|
194
|
-
export function isBtcAddress(options) {
|
|
195
|
-
return validator('isBtcAddress', function (input, context, _this) {
|
|
196
|
-
if (typeof input === 'string' && validatorJS.isBtcAddress(input))
|
|
197
|
-
return input;
|
|
198
|
-
context.fail(_this, `{{label}} is not a valid a BTC address`, input);
|
|
199
|
-
}, options);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Validates if value is a ETH (Ethereum) address.
|
|
203
|
-
* @validator isBtcAddress
|
|
204
|
-
*/
|
|
205
|
-
export function isETHAddress(options) {
|
|
206
|
-
return validator('isETHAddress', function (input, context, _this) {
|
|
207
|
-
if (typeof input === 'string' && validatorJS.isEthereumAddress(input))
|
|
208
|
-
return input;
|
|
209
|
-
context.fail(_this, `{{label}} is not a valid a ETH (Ethereum) address`, input);
|
|
210
|
-
}, options);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Validates if value a hash of type algorithm
|
|
214
|
-
* @validator isHash
|
|
215
|
-
*/
|
|
216
|
-
export function isHash(algorithm, options) {
|
|
217
|
-
return validator('isHash', function (input, context, _this) {
|
|
218
|
-
if (typeof input === 'string' && validatorJS.isHash(input, algorithm))
|
|
219
|
-
return input;
|
|
220
|
-
context.fail(_this, `{{label}} is not a valid ${algorithm} hash`, input);
|
|
221
|
-
}, options);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Validates if value is a Hex Color
|
|
225
|
-
* @validator isHexColor
|
|
226
|
-
*/
|
|
227
|
-
export function isHexColor(options) {
|
|
228
|
-
return validator('isHexColor', function (input, context, _this) {
|
|
229
|
-
if (typeof input === 'string' && validatorJS.isHexColor(input))
|
|
230
|
-
return input;
|
|
231
|
-
context.fail(_this, `{{label}} is not a valid Hex Color`, input);
|
|
232
|
-
}, options);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Validates if value a valid JWT token
|
|
236
|
-
* @validator isHash
|
|
237
|
-
*/
|
|
238
|
-
export function isJWT(options) {
|
|
239
|
-
return validator('isJWT', function (input, context, _this) {
|
|
240
|
-
if (typeof input === 'string' && validatorJS.isJWT(input))
|
|
241
|
-
return input;
|
|
242
|
-
context.fail(_this, `{{label}} is not a valid JWT token`, input);
|
|
243
|
-
}, options);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Validates if value a Lowercase string
|
|
247
|
-
* @validator isLowercase
|
|
248
|
-
*/
|
|
249
|
-
export function isLowercase(options) {
|
|
250
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
251
|
-
if (typeof input === 'string' && validatorJS.isLowercase(input))
|
|
252
|
-
return input;
|
|
253
|
-
context.fail(_this, `{{label}} is not a lowercase string`, input);
|
|
254
|
-
}, options);
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Validates if value a Uppercase string
|
|
258
|
-
* @validator isUppercase
|
|
259
|
-
*/
|
|
260
|
-
export function isUppercase(options) {
|
|
261
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
262
|
-
if (typeof input === 'string' && validatorJS.isUppercase(input))
|
|
263
|
-
return input;
|
|
264
|
-
context.fail(_this, `{{label}} is not an uppercase string`, input);
|
|
265
|
-
}, options);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Check if the string contains only letters (a-zA-Z).
|
|
269
|
-
* @validator isAlpha
|
|
270
|
-
*/
|
|
271
|
-
export function isAlpha(options) {
|
|
272
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
273
|
-
if (typeof input === 'string' && validatorJS.isAlpha(input))
|
|
274
|
-
return input;
|
|
275
|
-
context.fail(_this, `{{label}} is not an alpha string`, input);
|
|
276
|
-
}, options);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Check if the string contains only letters and numbers.
|
|
280
|
-
* @validator isAlphanumeric
|
|
281
|
-
*/
|
|
282
|
-
export function isAlphanumeric(options) {
|
|
283
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
284
|
-
if (typeof input === 'string' && validatorJS.isAlphanumeric(input))
|
|
285
|
-
return input;
|
|
286
|
-
context.fail(_this, `{{label}} is not an alphanumeric string`, input);
|
|
287
|
-
}, options);
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Check if the string contains ASCII chars only.
|
|
291
|
-
* @validator isAscii
|
|
292
|
-
*/
|
|
293
|
-
export function isAscii(options) {
|
|
294
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
295
|
-
if (typeof input === 'string' && validatorJS.isAscii(input))
|
|
296
|
-
return input;
|
|
297
|
-
context.fail(_this, `{{label}} is not an ascii string`, input);
|
|
298
|
-
}, options);
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Check if the string represents a decimal number,
|
|
302
|
-
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
|
|
303
|
-
* @validator isDecimal
|
|
304
|
-
*/
|
|
305
|
-
export function isDecimal(options) {
|
|
306
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
307
|
-
if (typeof input === 'string' && validatorJS.isDecimal(input))
|
|
308
|
-
return input;
|
|
309
|
-
context.fail(_this, `{{label}} is not an decimal number string`, input);
|
|
310
|
-
}, options);
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Check if the string is a hexadecimal number.
|
|
314
|
-
* @validator isHexadecimal
|
|
315
|
-
*/
|
|
316
|
-
export function isHexadecimal(options) {
|
|
317
|
-
return validator('isLowercase', function (input, context, _this) {
|
|
318
|
-
if (typeof input === 'string' && validatorJS.isHexadecimal(input))
|
|
319
|
-
return input;
|
|
320
|
-
context.fail(_this, `{{label}} is not an hexadecimal string`, input);
|
|
321
|
-
}, options);
|
|
322
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ValidationOptions } from '../core/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Validates if value is "null".
|
|
4
|
-
* @validator isNull
|
|
5
|
-
*/
|
|
6
|
-
export declare function isNull(options?: ValidationOptions): import("../core/validator.js").Validator<null, unknown, import("../core/types.js").ExecutionOptions>;
|
|
7
|
-
/**
|
|
8
|
-
* Validates if value is "null" or "undefined".
|
|
9
|
-
* @validator isNull
|
|
10
|
-
*/
|
|
11
|
-
export declare function isNullish(options?: ValidationOptions): import("../core/validator.js").Validator<null, unknown, import("../core/types.js").ExecutionOptions>;
|
|
12
|
-
/**
|
|
13
|
-
* Validates if value is not "undefined" nor "null"
|
|
14
|
-
* @validator isDefined
|
|
15
|
-
*/
|
|
16
|
-
export declare function isDefined(options?: ValidationOptions): import("../core/validator.js").Validator<any, unknown, import("../core/types.js").ExecutionOptions>;
|
|
17
|
-
/**
|
|
18
|
-
* Validates if value is "undefined"
|
|
19
|
-
* @validator isUndefined
|
|
20
|
-
*/
|
|
21
|
-
export declare function isUndefined(options?: ValidationOptions): import("../core/validator.js").Validator<any, unknown, import("../core/types.js").ExecutionOptions>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ValidationOptions } from '../core/index.js';
|
|
2
|
-
export interface IsRegExpOptions extends ValidationOptions {
|
|
3
|
-
formatName?: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Coerces given value to "UUID" format or returns undefined if nullish
|
|
7
|
-
* @validator uuid
|
|
8
|
-
*/
|
|
9
|
-
export declare function isRegExp(format: string | RegExp, options?: IsRegExpOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns length of an Array, String, ArrayBuffer, Buffer or any object with the "length" property.
|
|
3
|
-
* @validator getLength
|
|
4
|
-
*/
|
|
5
|
-
export declare const extractLength: () => import("../core/validator.js").Validator<number, ExtractLengthInput, import("../core/types.js").ExecutionOptions>;
|
|
6
|
-
type ExtractLengthInput = string | any[] | ArrayBuffer | {
|
|
7
|
-
length: number;
|
|
8
|
-
} | {
|
|
9
|
-
size: number;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Checks the length is at least "minValue"
|
|
13
|
-
* @validator lengthMin
|
|
14
|
-
*/
|
|
15
|
-
export declare const lengthMin: (minValue: number) => import("../core/validator.js").Validator<any, any, import("../core/types.js").ExecutionOptions>;
|
|
16
|
-
/**
|
|
17
|
-
* Checks if the length is at most "maxValue"
|
|
18
|
-
* @validator charLengthMax
|
|
19
|
-
*/
|
|
20
|
-
export declare const lengthMax: (maxValue: number) => import("../core/validator.js").Validator<any, any, import("../core/types.js").ExecutionOptions>;
|
|
21
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Nullish } from 'ts-gems';
|
|
2
|
-
import { ValidationOptions, Validator } from '../core/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Makes sub-rule optional
|
|
5
|
-
* @validator optional
|
|
6
|
-
*/
|
|
7
|
-
export declare function optional<T, I>(nested: Validator<T, I>, options?: ValidationOptions): Validator<Nullish<T>, Nullish<I>, import("../core/types.js").ExecutionOptions>;
|
|
8
|
-
/**
|
|
9
|
-
* Makes sub-rule required
|
|
10
|
-
* @validator required
|
|
11
|
-
*/
|
|
12
|
-
export declare function required<T, I>(nested: Validator<T, I>, options?: ValidationOptions): Validator<Nullish<T>, I, import("../core/types.js").ExecutionOptions>;
|
|
13
|
-
/**
|
|
14
|
-
* Validates if property exists
|
|
15
|
-
* @validator exists
|
|
16
|
-
*/
|
|
17
|
-
export declare function exists(options?: ValidationOptions): Validator<any, unknown, import("../core/types.js").ExecutionOptions>;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import * as validatorJS from 'validator';
|
|
2
|
-
import { ValidationOptions } from '../core/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Validates if value is an "UUID".
|
|
5
|
-
* @validator isUUID
|
|
6
|
-
*/
|
|
7
|
-
export declare function isUUID(version?: 1 | 2 | 3 | 4 | 5, options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
8
|
-
export interface IsEmailOptions extends ValidationOptions, validatorJS.IsEmailOptions {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Validates if value is a valid Email
|
|
12
|
-
* @validator isEmail
|
|
13
|
-
*/
|
|
14
|
-
export declare function isEmail(options?: IsEmailOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
15
|
-
export interface IsMobilePhoneOptions extends ValidationOptions, validatorJS.IsMobilePhoneOptions {
|
|
16
|
-
locale?: 'any' | validatorJS.MobilePhoneLocale | validatorJS.MobilePhoneLocale[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validates if value is a valid Email
|
|
20
|
-
* @validator isMobilePhone
|
|
21
|
-
*/
|
|
22
|
-
export declare function isMobilePhone(options?: IsMobilePhoneOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
23
|
-
/**
|
|
24
|
-
* Validates if value is an IP
|
|
25
|
-
* @validator isIP
|
|
26
|
-
*/
|
|
27
|
-
export declare function isIP(version?: 4 | 6, options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
28
|
-
/**
|
|
29
|
-
* Validates if value is an IP
|
|
30
|
-
* @validator isUUID
|
|
31
|
-
*/
|
|
32
|
-
export declare function isIPRange(version?: 4 | 6, options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
33
|
-
export interface IsMACAddressOptions extends ValidationOptions, validatorJS.IsMACAddressOptions {
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Validates if value is an MACAddress
|
|
37
|
-
* @validator isMACAddress
|
|
38
|
-
*/
|
|
39
|
-
export declare function isMACAddress(options?: IsMACAddressOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
40
|
-
/**
|
|
41
|
-
* Validates if value is a port number
|
|
42
|
-
* @validator isPort
|
|
43
|
-
*/
|
|
44
|
-
export declare function isPort(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
45
|
-
export interface IsURLOptions extends ValidationOptions, validatorJS.IsURLOptions {
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Validates if value is an MACAddress
|
|
49
|
-
* @validator isURL
|
|
50
|
-
*/
|
|
51
|
-
export declare function isURL(options?: IsURLOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
52
|
-
export interface Base64ValidatorOptions extends ValidationOptions, validatorJS.IsBase64Options {
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Validates if value is a "Base64" string.
|
|
56
|
-
* @validator isBase64
|
|
57
|
-
*/
|
|
58
|
-
export declare function isBase64(options?: Base64ValidatorOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
59
|
-
/**
|
|
60
|
-
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
61
|
-
* @validator isBIC
|
|
62
|
-
*/
|
|
63
|
-
export declare function isBIC(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
64
|
-
export interface CreditCardValidatorOptions extends ValidationOptions, validatorJS.IsCreditCardOptions {
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Validates if value is a "Base64" formatted string.
|
|
68
|
-
* @validator isCreditCard
|
|
69
|
-
*/
|
|
70
|
-
export declare function isCreditCard(options?: CreditCardValidatorOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
71
|
-
/**
|
|
72
|
-
* Validates if value is an IBAN (International Bank Account Number)
|
|
73
|
-
* @validator isEAN
|
|
74
|
-
*/
|
|
75
|
-
export declare function isIBAN(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
76
|
-
/**
|
|
77
|
-
* Validates if value is an passport number
|
|
78
|
-
* @validator isPassportNumber
|
|
79
|
-
*/
|
|
80
|
-
export declare function isPassportNumber(countryCode: string, options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
81
|
-
/**
|
|
82
|
-
* Validates if value is an EAN (European Article Number)
|
|
83
|
-
* @validator isEAN
|
|
84
|
-
*/
|
|
85
|
-
export declare function isEAN(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
86
|
-
export interface IsFQDNOptions extends ValidationOptions, validatorJS.IsFQDNOptions {
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Validates if value is an FQDN
|
|
90
|
-
* @validator isFQDN
|
|
91
|
-
*/
|
|
92
|
-
export declare function isFQDN(options?: IsFQDNOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
93
|
-
export interface IsISSNOptions extends ValidationOptions, validatorJS.IsISSNOptions {
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Validates if value is an ISSN
|
|
97
|
-
* @validator isISSN
|
|
98
|
-
*/
|
|
99
|
-
export declare function isISSN(options?: IsISSNOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
100
|
-
/**
|
|
101
|
-
* Validates if value is an VAT number
|
|
102
|
-
* @validator isVAT
|
|
103
|
-
*/
|
|
104
|
-
export declare function isVAT(countryCode: string, options?: IsISSNOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
105
|
-
/**
|
|
106
|
-
* Validates if value is a BTC address.
|
|
107
|
-
* @validator isBtcAddress
|
|
108
|
-
*/
|
|
109
|
-
export declare function isBtcAddress(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
110
|
-
/**
|
|
111
|
-
* Validates if value is a ETH (Ethereum) address.
|
|
112
|
-
* @validator isBtcAddress
|
|
113
|
-
*/
|
|
114
|
-
export declare function isETHAddress(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
115
|
-
export type HashAlgorithm = 'crc32' | 'crc32b' | 'md4' | 'md5' | 'ripemd128' | 'ripemd160' | 'sha1' | 'sha256' | 'sha384' | 'sha512' | 'tiger128' | 'tiger160' | 'tiger192';
|
|
116
|
-
/**
|
|
117
|
-
* Validates if value a hash of type algorithm
|
|
118
|
-
* @validator isHash
|
|
119
|
-
*/
|
|
120
|
-
export declare function isHash(algorithm: HashAlgorithm, options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
121
|
-
/**
|
|
122
|
-
* Validates if value is a Hex Color
|
|
123
|
-
* @validator isHexColor
|
|
124
|
-
*/
|
|
125
|
-
export declare function isHexColor(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
126
|
-
/**
|
|
127
|
-
* Validates if value a valid JWT token
|
|
128
|
-
* @validator isHash
|
|
129
|
-
*/
|
|
130
|
-
export declare function isJWT(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
131
|
-
/**
|
|
132
|
-
* Validates if value a Lowercase string
|
|
133
|
-
* @validator isLowercase
|
|
134
|
-
*/
|
|
135
|
-
export declare function isLowercase(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
136
|
-
/**
|
|
137
|
-
* Validates if value a Uppercase string
|
|
138
|
-
* @validator isUppercase
|
|
139
|
-
*/
|
|
140
|
-
export declare function isUppercase(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
141
|
-
/**
|
|
142
|
-
* Check if the string contains only letters (a-zA-Z).
|
|
143
|
-
* @validator isAlpha
|
|
144
|
-
*/
|
|
145
|
-
export declare function isAlpha(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
146
|
-
/**
|
|
147
|
-
* Check if the string contains only letters and numbers.
|
|
148
|
-
* @validator isAlphanumeric
|
|
149
|
-
*/
|
|
150
|
-
export declare function isAlphanumeric(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
151
|
-
/**
|
|
152
|
-
* Check if the string contains ASCII chars only.
|
|
153
|
-
* @validator isAscii
|
|
154
|
-
*/
|
|
155
|
-
export declare function isAscii(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
156
|
-
/**
|
|
157
|
-
* Check if the string represents a decimal number,
|
|
158
|
-
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
|
|
159
|
-
* @validator isDecimal
|
|
160
|
-
*/
|
|
161
|
-
export declare function isDecimal(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|
|
162
|
-
/**
|
|
163
|
-
* Check if the string is a hexadecimal number.
|
|
164
|
-
* @validator isHexadecimal
|
|
165
|
-
*/
|
|
166
|
-
export declare function isHexadecimal(options?: ValidationOptions): import("../core/validator.js").Validator<string, string, import("../core/types.js").ExecutionOptions>;
|