@kklab/fortress-validator 1.0.13 → 1.0.14
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/README.md +25 -17
- package/dist/FieldValidator.d.ts +73 -41
- package/dist/index.js +439 -283
- package/dist/index.umd.js +1 -1
- package/dist/rules/arrayLength.d.ts +6 -0
- package/dist/rules/arrayLengthBetween.d.ts +7 -0
- package/dist/rules/arrayLengthGt.d.ts +6 -0
- package/dist/rules/arrayLengthGte.d.ts +6 -0
- package/dist/rules/arrayLengthLt.d.ts +6 -0
- package/dist/rules/arrayLengthLte.d.ts +6 -0
- package/dist/rules/fileSizeBetween.d.ts +7 -0
- package/dist/rules/fileSizeGt.d.ts +6 -0
- package/dist/rules/fileSizeGte.d.ts +6 -0
- package/dist/rules/fileSizeLt.d.ts +6 -0
- package/dist/rules/fileSizeLte.d.ts +6 -0
- package/dist/rules/gt.d.ts +6 -0
- package/dist/rules/gte.d.ts +6 -0
- package/dist/rules/lt.d.ts +6 -0
- package/dist/rules/lte.d.ts +6 -0
- package/dist/rules/stringLengthBetween.d.ts +7 -0
- package/dist/rules/stringLengthGt.d.ts +6 -0
- package/dist/rules/stringLengthGte.d.ts +6 -0
- package/dist/rules/stringLengthLt.d.ts +6 -0
- package/dist/rules/stringLengthLte.d.ts +6 -0
- package/package.json +1 -1
- package/dist/rules/betweenLength.d.ts +0 -7
- package/dist/rules/fileBetweenSize.d.ts +0 -7
- package/dist/rules/fileMaxSize.d.ts +0 -6
- package/dist/rules/fileMinSize.d.ts +0 -6
- package/dist/rules/length.d.ts +0 -6
- package/dist/rules/max.d.ts +0 -6
- package/dist/rules/maxLength.d.ts +0 -6
- package/dist/rules/min.d.ts +0 -6
- package/dist/rules/minLength.d.ts +0 -6
- package/dist/rules/stringBetweenLength.d.ts +0 -7
- package/dist/rules/stringMaxLength.d.ts +0 -6
- package/dist/rules/stringMinLength.d.ts +0 -6
package/README.md
CHANGED
|
@@ -72,10 +72,15 @@ const result = validator
|
|
|
72
72
|
| `alphaDashDot` | Passes if the field's value contains only letters, numbers, dashes, underscores and dots. |
|
|
73
73
|
| `alphaNum` | Passes if the field's value contains only letters and numbers. |
|
|
74
74
|
| `array` | Passes if the field's value is an array. |
|
|
75
|
+
| `arrayLength` | Passes if the field's length matches the specified length. |
|
|
76
|
+
| `arrayLengthBetween` | Passes if the field's length is between the specified minimum and maximum lengths. |
|
|
77
|
+
| `arrayLengthGt` | Passes if the field's length is greater than the specified length. |
|
|
78
|
+
| `arrayLengthGte` | Passes if the field's length is greater than or equal to the specified length. |
|
|
79
|
+
| `arrayLengthLt` | Passes if the field's length is less than the specified length. |
|
|
80
|
+
| `arrayLengthLte` | Passes if the field's length is less than or equal to the specified length. |
|
|
75
81
|
| `ascii` | Passes if the field's value contains only ASCII characters and symbols. |
|
|
76
82
|
| `before` | Passes if the field's value is a date that occurs before the specified date. |
|
|
77
83
|
| `between` | Passes if the field's value is between the specified minimum and maximum values. |
|
|
78
|
-
| `betweenLength` | Passes if the field's value is between the specified minimum and maximum lengths. |
|
|
79
84
|
| `boolean` | Passes if the field's value is a boolean. |
|
|
80
85
|
| `containsAll` | Passes if the field's value contains all of the specified values. |
|
|
81
86
|
| `containsAny` | Passes if the field's value contains at least one of the specified values. |
|
|
@@ -88,13 +93,17 @@ const result = validator
|
|
|
88
93
|
| `endsWith` | Passes if the field's value ends with the specified value. |
|
|
89
94
|
| `equals` | Passes if the field's value is equal to the specified value. |
|
|
90
95
|
| `file` | Passes if the field's value is a file. |
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
96
|
+
| `fileSize` | Passes if the field's file size matches the specified file size. |
|
|
97
|
+
| `fileSizeBetween` | Passes if the field's file size is between the specified minimum and maximum file sizes. |
|
|
98
|
+
| `fileSizeGt` | Passes if the field's file size is greater than the specified file size. |
|
|
99
|
+
| `fileSizeGte` | Passes if the field's file size is greater than or equal to the specified file size. |
|
|
100
|
+
| `fileSizeLt` | Passes if the field's file size is less than the specified file size. |
|
|
101
|
+
| `fileSizeLte` | Passes if the field's file size is less than or equal to the specified file size. |
|
|
102
|
+
| `gt` | Passes if the field's value is greater than the specified value. |
|
|
103
|
+
| `gte` | Passes if the field's value is greater than or equal to the specified value. |
|
|
104
|
+
| `http` | Passes if the field's value starts with the "http://" protocol. |
|
|
105
|
+
| `httpOrHttps` | Passes if the field's value starts with the "http://" or "https://" protocols. |
|
|
106
|
+
| `https` | Passes if the field's value starts with the "https://" protocol. |
|
|
98
107
|
| `integer` | Passes if the field's value is an integer. |
|
|
99
108
|
| `ip` | Passes if the field's value is a valid IP address. |
|
|
100
109
|
| `ipv4` | Passes if the field's value is a valid IPv4 address. |
|
|
@@ -102,12 +111,9 @@ const result = validator
|
|
|
102
111
|
| `iso8601` | Passes if the field's value is a valid ISO 8601 date. |
|
|
103
112
|
| `json` | Passes if the field's value is a valid JSON string. |
|
|
104
113
|
| `jsonSchema` | Passes if the field's value matches the specified JSON schema. |
|
|
105
|
-
| `length` | Passes if the field's value matches the specified length. |
|
|
106
114
|
| `lowercase` | Passes if the field's value contains only lowercase characters. |
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `min` | Passes if the field's value is at least the specified minimum. |
|
|
110
|
-
| `minLength` | Passes if the field's value is at least the specified minimum length. |
|
|
115
|
+
| `lt` | Passes if the field's value is less than the specified value. |
|
|
116
|
+
| `lte` | Passes if the field's value is less than or equal to the specified value. |
|
|
111
117
|
| `notContainsAll` | Passes if the field's value does not contain all of the specified values together. |
|
|
112
118
|
| `notContainsAny` | Passes if the field's value does not contain any of the specified values. |
|
|
113
119
|
| `notEquals` | Passes if the field's value is not equal to the specified value. |
|
|
@@ -124,12 +130,14 @@ const result = validator
|
|
|
124
130
|
| `size` | Passes if the field's value matches the specified size. |
|
|
125
131
|
| `startsWith` | Passes if the field's value starts with the specified value. |
|
|
126
132
|
| `string` | Passes if the field's value is a string. |
|
|
127
|
-
| `stringBetweenLength` | Passes if the field's value is between the specified minimum and maximum string lengths. |
|
|
128
133
|
| `stringContainsAll` | Passes if the field's value contains all of the specified text. |
|
|
129
134
|
| `stringContainsAny` | Passes if the field's value contains at least one of the specified text. |
|
|
130
|
-
| `stringLength` | Passes if the field's
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
135
|
+
| `stringLength` | Passes if the field's string length matches the specified string length. |
|
|
136
|
+
| `stringLengthBetween` | Passes if the field's string length is between the specified minimum and maximum string lengths. |
|
|
137
|
+
| `stringLengthGt` | Passes if the field's string length is greater than the specified string length. |
|
|
138
|
+
| `stringLengthGte` | Passes if the field's string length is greater than or equal to the specified string length. |
|
|
139
|
+
| `stringLengthLt` | Passes if the field's string length is less than the specified string length. |
|
|
140
|
+
| `stringLengthLte` | Passes if the field's string length is less than or equal to the specified string length. |
|
|
133
141
|
| `stringNotContainsAll` | Passes if the field's value does not contain all of the specified text together. |
|
|
134
142
|
| `stringNotContainsAny` | Passes if the field's value does not contain any of the specified text. |
|
|
135
143
|
| `subsetOf` | Passes if the field's value is a subset of the specified values. |
|
package/dist/FieldValidator.d.ts
CHANGED
|
@@ -61,6 +61,30 @@ declare class FieldValidator {
|
|
|
61
61
|
* Passes if the field's value is an array.
|
|
62
62
|
*/
|
|
63
63
|
array(): this;
|
|
64
|
+
/**
|
|
65
|
+
* Passes if the field's length matches the specified length.
|
|
66
|
+
*/
|
|
67
|
+
arrayLength(length: number): this;
|
|
68
|
+
/**
|
|
69
|
+
* Passes if the field's length is between the specified minimum and maximum lengths.
|
|
70
|
+
*/
|
|
71
|
+
arrayLengthBetween(min: number, max: number): this;
|
|
72
|
+
/**
|
|
73
|
+
* Passes if the field's length is greater than the specified length.
|
|
74
|
+
*/
|
|
75
|
+
arrayLengthGt(length: number): this;
|
|
76
|
+
/**
|
|
77
|
+
* Passes if the field's length is greater than or equal to the specified length.
|
|
78
|
+
*/
|
|
79
|
+
arrayLengthGte(length: number): this;
|
|
80
|
+
/**
|
|
81
|
+
* Passes if the field's length is less than the specified length.
|
|
82
|
+
*/
|
|
83
|
+
arrayLengthLt(length: number): this;
|
|
84
|
+
/**
|
|
85
|
+
* Passes if the field's length is less than or equal to the specified length.
|
|
86
|
+
*/
|
|
87
|
+
arrayLengthLte(length: number): this;
|
|
64
88
|
/**
|
|
65
89
|
* Passes if the field's value contains only ASCII characters and symbols.
|
|
66
90
|
*/
|
|
@@ -73,10 +97,6 @@ declare class FieldValidator {
|
|
|
73
97
|
* Passes if the field's value is between the specified minimum and maximum values.
|
|
74
98
|
*/
|
|
75
99
|
between(min: number, max: number): this;
|
|
76
|
-
/**
|
|
77
|
-
* Passes if the field's value is between the specified minimum and maximum lengths.
|
|
78
|
-
*/
|
|
79
|
-
betweenLength(min: number, max: number): this;
|
|
80
100
|
/**
|
|
81
101
|
* Passes if the field's value is a boolean.
|
|
82
102
|
*/
|
|
@@ -126,21 +146,37 @@ declare class FieldValidator {
|
|
|
126
146
|
*/
|
|
127
147
|
file(): this;
|
|
128
148
|
/**
|
|
129
|
-
* Passes if the field's
|
|
149
|
+
* Passes if the field's file size matches the specified file size.
|
|
150
|
+
*/
|
|
151
|
+
fileSize(size: number): this;
|
|
152
|
+
/**
|
|
153
|
+
* Passes if the field's file size is between the specified minimum and maximum file sizes.
|
|
130
154
|
*/
|
|
131
|
-
|
|
155
|
+
fileSizeBetween(min: number, max: number): this;
|
|
132
156
|
/**
|
|
133
|
-
* Passes if the field's
|
|
157
|
+
* Passes if the field's file size is greater than the specified file size.
|
|
134
158
|
*/
|
|
135
|
-
|
|
159
|
+
fileSizeGt(size: number): this;
|
|
136
160
|
/**
|
|
137
|
-
* Passes if the field's
|
|
161
|
+
* Passes if the field's file size is greater than or equal to the specified file size.
|
|
138
162
|
*/
|
|
139
|
-
|
|
163
|
+
fileSizeGte(size: number): this;
|
|
140
164
|
/**
|
|
141
|
-
* Passes if the field's
|
|
165
|
+
* Passes if the field's file size is less than the specified file size.
|
|
142
166
|
*/
|
|
143
|
-
|
|
167
|
+
fileSizeLt(size: number): this;
|
|
168
|
+
/**
|
|
169
|
+
* Passes if the field's file size is less than or equal to the specified file size.
|
|
170
|
+
*/
|
|
171
|
+
fileSizeLte(size: number): this;
|
|
172
|
+
/**
|
|
173
|
+
* Passes if the field's value is greater than the specified value.
|
|
174
|
+
*/
|
|
175
|
+
gt(value: number): this;
|
|
176
|
+
/**
|
|
177
|
+
* Passes if the field's value is greater than or equal to the specified value.
|
|
178
|
+
*/
|
|
179
|
+
gte(value: number): this;
|
|
144
180
|
/**
|
|
145
181
|
* Passes if the field's value starts with the "http://" protocol.
|
|
146
182
|
*/
|
|
@@ -181,30 +217,18 @@ declare class FieldValidator {
|
|
|
181
217
|
* Passes if the field's value matches the specified JSON schema.
|
|
182
218
|
*/
|
|
183
219
|
jsonSchema(schema: Record<string, unknown>): this;
|
|
184
|
-
/**
|
|
185
|
-
* Passes if the field's value matches the specified length.
|
|
186
|
-
*/
|
|
187
|
-
length(length: number): this;
|
|
188
220
|
/**
|
|
189
221
|
* Passes if the field's value contains only lowercase characters.
|
|
190
222
|
*/
|
|
191
223
|
lowercase(): this;
|
|
192
224
|
/**
|
|
193
|
-
* Passes if the field's value is
|
|
194
|
-
*/
|
|
195
|
-
max(max: number): this;
|
|
196
|
-
/**
|
|
197
|
-
* Passes if the field's value is not greater than the specified maximum length.
|
|
198
|
-
*/
|
|
199
|
-
maxLength(length: number): this;
|
|
200
|
-
/**
|
|
201
|
-
* Passes if the field's value is at least the specified minimum.
|
|
225
|
+
* Passes if the field's value is less than the specified value.
|
|
202
226
|
*/
|
|
203
|
-
|
|
227
|
+
lt(value: number): this;
|
|
204
228
|
/**
|
|
205
|
-
* Passes if the field's value is
|
|
229
|
+
* Passes if the field's value is less than or equal to the specified value.
|
|
206
230
|
*/
|
|
207
|
-
|
|
231
|
+
lte(value: number): this;
|
|
208
232
|
/**
|
|
209
233
|
* Passes if the field's value does not contain all of the specified values together.
|
|
210
234
|
*/
|
|
@@ -225,10 +249,6 @@ declare class FieldValidator {
|
|
|
225
249
|
* Passes if the field's value is not a subset of the specified values.
|
|
226
250
|
*/
|
|
227
251
|
notSubsetOf(values: string[]): this;
|
|
228
|
-
/**
|
|
229
|
-
* Passes if the field's value starts with the specified protocol.
|
|
230
|
-
*/
|
|
231
|
-
protocol(protocol: string | string[]): this;
|
|
232
252
|
/**
|
|
233
253
|
* Passes if the field's value is a number.
|
|
234
254
|
*/
|
|
@@ -241,6 +261,10 @@ declare class FieldValidator {
|
|
|
241
261
|
* Passes if the field's value is one of the specified values.
|
|
242
262
|
*/
|
|
243
263
|
oneOf(values: unknown[]): this;
|
|
264
|
+
/**
|
|
265
|
+
* Passes if the field's value starts with the specified protocol.
|
|
266
|
+
*/
|
|
267
|
+
protocol(protocol: string | string[]): this;
|
|
244
268
|
/**
|
|
245
269
|
* Passes if the field's value matches the specified regular expression.
|
|
246
270
|
*/
|
|
@@ -269,10 +293,6 @@ declare class FieldValidator {
|
|
|
269
293
|
* Passes if the field's value is a string.
|
|
270
294
|
*/
|
|
271
295
|
string(): this;
|
|
272
|
-
/**
|
|
273
|
-
* Passes if the field's value is between the specified minimum and maximum string lengths.
|
|
274
|
-
*/
|
|
275
|
-
stringBetweenLength(min: number, max: number): this;
|
|
276
296
|
/**
|
|
277
297
|
* Passes if the field's value contains all of the specified text.
|
|
278
298
|
*/
|
|
@@ -282,17 +302,29 @@ declare class FieldValidator {
|
|
|
282
302
|
*/
|
|
283
303
|
stringContainsAny(values: string[]): this;
|
|
284
304
|
/**
|
|
285
|
-
* Passes if the field's
|
|
305
|
+
* Passes if the field's string length matches the specified string length.
|
|
286
306
|
*/
|
|
287
307
|
stringLength(length: number): this;
|
|
288
308
|
/**
|
|
289
|
-
* Passes if the field's
|
|
309
|
+
* Passes if the field's string length is between the specified minimum and maximum string lengths.
|
|
310
|
+
*/
|
|
311
|
+
stringLengthBetween(min: number, max: number): this;
|
|
312
|
+
/**
|
|
313
|
+
* Passes if the field's string length is greater than the specified string length.
|
|
314
|
+
*/
|
|
315
|
+
stringLengthGt(length: number): this;
|
|
316
|
+
/**
|
|
317
|
+
* Passes if the field's string length is greater than or equal to the specified string length.
|
|
318
|
+
*/
|
|
319
|
+
stringLengthGte(length: number): this;
|
|
320
|
+
/**
|
|
321
|
+
* Passes if the field's string length is less than the specified string length.
|
|
290
322
|
*/
|
|
291
|
-
|
|
323
|
+
stringLengthLt(length: number): this;
|
|
292
324
|
/**
|
|
293
|
-
* Passes if the field's
|
|
325
|
+
* Passes if the field's string length is less than or equal to the specified string length.
|
|
294
326
|
*/
|
|
295
|
-
|
|
327
|
+
stringLengthLte(length: number): this;
|
|
296
328
|
/**
|
|
297
329
|
* Passes if the field's value does not contain all of the specified text together.
|
|
298
330
|
*/
|