@twin.org/core 0.0.1-next.1
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/LICENSE +201 -0
- package/README.md +29 -0
- package/dist/cjs/index.cjs +4221 -0
- package/dist/esm/index.mjs +4184 -0
- package/dist/types/encoding/base32.d.ts +18 -0
- package/dist/types/encoding/base64.d.ts +24 -0
- package/dist/types/encoding/base64Url.d.ts +18 -0
- package/dist/types/errors/alreadyExistsError.d.ts +18 -0
- package/dist/types/errors/baseError.d.ts +103 -0
- package/dist/types/errors/conflictError.d.ts +19 -0
- package/dist/types/errors/generalError.d.ts +20 -0
- package/dist/types/errors/guardError.d.ts +19 -0
- package/dist/types/errors/notFoundError.d.ts +18 -0
- package/dist/types/errors/notImplementedError.d.ts +16 -0
- package/dist/types/errors/notSupportedError.d.ts +17 -0
- package/dist/types/errors/unauthorizedError.d.ts +17 -0
- package/dist/types/errors/unprocessableError.d.ts +20 -0
- package/dist/types/errors/validationError.d.ts +18 -0
- package/dist/types/factories/componentFactory.d.ts +6 -0
- package/dist/types/factories/factory.d.ts +67 -0
- package/dist/types/helpers/arrayHelper.d.ts +12 -0
- package/dist/types/helpers/errorHelper.d.ts +24 -0
- package/dist/types/helpers/filenameHelper.d.ts +11 -0
- package/dist/types/helpers/hexHelper.d.ts +30 -0
- package/dist/types/helpers/jsonHelper.d.ts +29 -0
- package/dist/types/helpers/objectHelper.d.ts +74 -0
- package/dist/types/helpers/randomHelper.d.ts +11 -0
- package/dist/types/helpers/stringHelper.d.ts +90 -0
- package/dist/types/index.d.ts +46 -0
- package/dist/types/models/IComponent.d.ts +29 -0
- package/dist/types/models/IError.d.ts +31 -0
- package/dist/types/models/IKeyValue.d.ts +13 -0
- package/dist/types/models/ILabelledValue.d.ts +13 -0
- package/dist/types/models/ILocale.d.ts +13 -0
- package/dist/types/models/ILocaleDictionary.d.ts +6 -0
- package/dist/types/models/ILocalesIndex.d.ts +10 -0
- package/dist/types/models/IPatchOperation.d.ts +21 -0
- package/dist/types/models/IUrlParts.d.ts +29 -0
- package/dist/types/models/IValidationFailure.d.ts +23 -0
- package/dist/types/models/compressionType.d.ts +17 -0
- package/dist/types/types/bitString.d.ts +41 -0
- package/dist/types/types/url.d.ts +56 -0
- package/dist/types/types/urn.d.ts +93 -0
- package/dist/types/utils/asyncCache.d.ts +33 -0
- package/dist/types/utils/coerce.d.ts +61 -0
- package/dist/types/utils/compression.d.ts +20 -0
- package/dist/types/utils/converter.d.ts +85 -0
- package/dist/types/utils/guards.d.ts +190 -0
- package/dist/types/utils/i18n.d.ts +81 -0
- package/dist/types/utils/is.d.ts +205 -0
- package/dist/types/utils/validation.d.ts +245 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/AlreadyExistsError.md +375 -0
- package/docs/reference/classes/ArrayHelper.md +37 -0
- package/docs/reference/classes/AsyncCache.md +117 -0
- package/docs/reference/classes/Base32.md +57 -0
- package/docs/reference/classes/Base64.md +74 -0
- package/docs/reference/classes/Base64Url.md +54 -0
- package/docs/reference/classes/BaseError.md +344 -0
- package/docs/reference/classes/BitString.md +123 -0
- package/docs/reference/classes/Coerce.md +209 -0
- package/docs/reference/classes/Compression.md +61 -0
- package/docs/reference/classes/ConflictError.md +379 -0
- package/docs/reference/classes/Converter.md +285 -0
- package/docs/reference/classes/ErrorHelper.md +73 -0
- package/docs/reference/classes/Factory.md +221 -0
- package/docs/reference/classes/FilenameHelper.md +33 -0
- package/docs/reference/classes/GeneralError.md +375 -0
- package/docs/reference/classes/GuardError.md +379 -0
- package/docs/reference/classes/Guards.md +711 -0
- package/docs/reference/classes/HexHelper.md +97 -0
- package/docs/reference/classes/I18n.md +237 -0
- package/docs/reference/classes/Is.md +693 -0
- package/docs/reference/classes/JsonHelper.md +92 -0
- package/docs/reference/classes/NotFoundError.md +375 -0
- package/docs/reference/classes/NotImplementedError.md +367 -0
- package/docs/reference/classes/NotSupportedError.md +371 -0
- package/docs/reference/classes/ObjectHelper.md +287 -0
- package/docs/reference/classes/RandomHelper.md +33 -0
- package/docs/reference/classes/StringHelper.md +270 -0
- package/docs/reference/classes/UnauthorizedError.md +371 -0
- package/docs/reference/classes/UnprocessableError.md +375 -0
- package/docs/reference/classes/Url.md +167 -0
- package/docs/reference/classes/Urn.md +295 -0
- package/docs/reference/classes/Validation.md +821 -0
- package/docs/reference/classes/ValidationError.md +371 -0
- package/docs/reference/index.md +60 -0
- package/docs/reference/interfaces/IComponent.md +79 -0
- package/docs/reference/interfaces/IError.md +55 -0
- package/docs/reference/interfaces/IKeyValue.md +23 -0
- package/docs/reference/interfaces/ILabelledValue.md +23 -0
- package/docs/reference/interfaces/ILocale.md +19 -0
- package/docs/reference/interfaces/ILocaleDictionary.md +7 -0
- package/docs/reference/interfaces/ILocalesIndex.md +11 -0
- package/docs/reference/interfaces/IPatchOperation.md +35 -0
- package/docs/reference/interfaces/IUrlParts.md +51 -0
- package/docs/reference/interfaces/IValidationFailure.md +39 -0
- package/docs/reference/type-aliases/CompressionType.md +5 -0
- package/docs/reference/variables/ComponentFactory.md +5 -0
- package/docs/reference/variables/CompressionType.md +19 -0
- package/locales/en.json +98 -0
- package/package.json +65 -0
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
# Class: Validation
|
|
2
|
+
|
|
3
|
+
Class to handle validation operations.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new Validation()
|
|
8
|
+
|
|
9
|
+
> **new Validation**(): [`Validation`](Validation.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`Validation`](Validation.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### empty()
|
|
18
|
+
|
|
19
|
+
> `static` **empty**(`property`, `value`, `failures`, `fieldNameResource`?): value is undefined \| null
|
|
20
|
+
|
|
21
|
+
Is the property null or undefined.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **property**: `string`
|
|
26
|
+
|
|
27
|
+
The name of the property.
|
|
28
|
+
|
|
29
|
+
• **value**: `unknown`
|
|
30
|
+
|
|
31
|
+
The value to test.
|
|
32
|
+
|
|
33
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
34
|
+
|
|
35
|
+
The list of failures to add to.
|
|
36
|
+
|
|
37
|
+
• **fieldNameResource?**: `string`
|
|
38
|
+
|
|
39
|
+
Optional i18n resource of the field name to display in the message.
|
|
40
|
+
|
|
41
|
+
#### Returns
|
|
42
|
+
|
|
43
|
+
value is undefined \| null
|
|
44
|
+
|
|
45
|
+
True if the value is a empty.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### notEmpty()
|
|
50
|
+
|
|
51
|
+
> `static` **notEmpty**(`property`, `value`, `failures`, `fieldNameResource`?): `boolean`
|
|
52
|
+
|
|
53
|
+
Is the property is not null or undefined.
|
|
54
|
+
|
|
55
|
+
#### Parameters
|
|
56
|
+
|
|
57
|
+
• **property**: `string`
|
|
58
|
+
|
|
59
|
+
The name of the property.
|
|
60
|
+
|
|
61
|
+
• **value**: `unknown`
|
|
62
|
+
|
|
63
|
+
The value to test.
|
|
64
|
+
|
|
65
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
66
|
+
|
|
67
|
+
The list of failures to add to.
|
|
68
|
+
|
|
69
|
+
• **fieldNameResource?**: `string`
|
|
70
|
+
|
|
71
|
+
Optional i18n resource of the field name to display in the message.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`boolean`
|
|
76
|
+
|
|
77
|
+
True if the value is a not empty.
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### string()
|
|
82
|
+
|
|
83
|
+
> `static` **string**(`property`, `value`, `failures`, `fieldNameResource`?, `options`?): `value is string`
|
|
84
|
+
|
|
85
|
+
Is the property a string.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
• **property**: `string`
|
|
90
|
+
|
|
91
|
+
The name of the property.
|
|
92
|
+
|
|
93
|
+
• **value**: `unknown`
|
|
94
|
+
|
|
95
|
+
The value to test.
|
|
96
|
+
|
|
97
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
98
|
+
|
|
99
|
+
The list of failures to add to.
|
|
100
|
+
|
|
101
|
+
• **fieldNameResource?**: `string`
|
|
102
|
+
|
|
103
|
+
Optional i18n resource of the field name to display in the message.
|
|
104
|
+
|
|
105
|
+
• **options?**
|
|
106
|
+
|
|
107
|
+
Additional options for the validation.
|
|
108
|
+
|
|
109
|
+
• **options.minLength?**: `number`
|
|
110
|
+
|
|
111
|
+
The minimum length of the string.
|
|
112
|
+
|
|
113
|
+
• **options.maxLength?**: `number`
|
|
114
|
+
|
|
115
|
+
The maximum length of the string.
|
|
116
|
+
|
|
117
|
+
#### Returns
|
|
118
|
+
|
|
119
|
+
`value is string`
|
|
120
|
+
|
|
121
|
+
True if the value is a valid string.
|
|
122
|
+
|
|
123
|
+
***
|
|
124
|
+
|
|
125
|
+
### stringValue()
|
|
126
|
+
|
|
127
|
+
> `static` **stringValue**(`property`, `value`, `failures`, `fieldNameResource`?, `options`?): `value is string`
|
|
128
|
+
|
|
129
|
+
Is the property a string with a value.
|
|
130
|
+
|
|
131
|
+
#### Parameters
|
|
132
|
+
|
|
133
|
+
• **property**: `string`
|
|
134
|
+
|
|
135
|
+
The name of the property.
|
|
136
|
+
|
|
137
|
+
• **value**: `unknown`
|
|
138
|
+
|
|
139
|
+
The value to test.
|
|
140
|
+
|
|
141
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
142
|
+
|
|
143
|
+
The list of failures to add to.
|
|
144
|
+
|
|
145
|
+
• **fieldNameResource?**: `string`
|
|
146
|
+
|
|
147
|
+
Optional i18n resource of the field name to display in the message.
|
|
148
|
+
|
|
149
|
+
• **options?**
|
|
150
|
+
|
|
151
|
+
Additional options for the validation.
|
|
152
|
+
|
|
153
|
+
• **options.minLength?**: `number`
|
|
154
|
+
|
|
155
|
+
The minimum length of the string.
|
|
156
|
+
|
|
157
|
+
• **options.maxLength?**: `number`
|
|
158
|
+
|
|
159
|
+
The maximum length of the string.
|
|
160
|
+
|
|
161
|
+
#### Returns
|
|
162
|
+
|
|
163
|
+
`value is string`
|
|
164
|
+
|
|
165
|
+
True if the value is a valid string.
|
|
166
|
+
|
|
167
|
+
***
|
|
168
|
+
|
|
169
|
+
### number()
|
|
170
|
+
|
|
171
|
+
> `static` **number**(`property`, `value`, `failures`, `fieldNameResource`?, `options`?): `value is number`
|
|
172
|
+
|
|
173
|
+
Is the property a number.
|
|
174
|
+
|
|
175
|
+
#### Parameters
|
|
176
|
+
|
|
177
|
+
• **property**: `string`
|
|
178
|
+
|
|
179
|
+
The name of the property.
|
|
180
|
+
|
|
181
|
+
• **value**: `unknown`
|
|
182
|
+
|
|
183
|
+
The value to test.
|
|
184
|
+
|
|
185
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
186
|
+
|
|
187
|
+
The list of failures to add to.
|
|
188
|
+
|
|
189
|
+
• **fieldNameResource?**: `string`
|
|
190
|
+
|
|
191
|
+
Optional i18n resource of the field name to display in the message.
|
|
192
|
+
|
|
193
|
+
• **options?**
|
|
194
|
+
|
|
195
|
+
Additional options for the validation.
|
|
196
|
+
|
|
197
|
+
• **options.minValue?**: `number`
|
|
198
|
+
|
|
199
|
+
The minimum value of the number.
|
|
200
|
+
|
|
201
|
+
• **options.maxValue?**: `number`
|
|
202
|
+
|
|
203
|
+
The maximum value of the number.
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
`value is number`
|
|
208
|
+
|
|
209
|
+
True if the value is a valid number.
|
|
210
|
+
|
|
211
|
+
***
|
|
212
|
+
|
|
213
|
+
### integer()
|
|
214
|
+
|
|
215
|
+
> `static` **integer**(`property`, `value`, `failures`, `fieldNameResource`?, `options`?): `value is number`
|
|
216
|
+
|
|
217
|
+
Is the property an integer.
|
|
218
|
+
|
|
219
|
+
#### Parameters
|
|
220
|
+
|
|
221
|
+
• **property**: `string`
|
|
222
|
+
|
|
223
|
+
The name of the property.
|
|
224
|
+
|
|
225
|
+
• **value**: `unknown`
|
|
226
|
+
|
|
227
|
+
The value to test.
|
|
228
|
+
|
|
229
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
230
|
+
|
|
231
|
+
The list of failures to add to.
|
|
232
|
+
|
|
233
|
+
• **fieldNameResource?**: `string`
|
|
234
|
+
|
|
235
|
+
Optional i18n resource of the field name to display in the message.
|
|
236
|
+
|
|
237
|
+
• **options?**
|
|
238
|
+
|
|
239
|
+
Additional options for the validation.
|
|
240
|
+
|
|
241
|
+
• **options.minValue?**: `number`
|
|
242
|
+
|
|
243
|
+
The minimum value of the integer.
|
|
244
|
+
|
|
245
|
+
• **options.maxValue?**: `number`
|
|
246
|
+
|
|
247
|
+
The maximum value of the integer.
|
|
248
|
+
|
|
249
|
+
#### Returns
|
|
250
|
+
|
|
251
|
+
`value is number`
|
|
252
|
+
|
|
253
|
+
True if the value is a valid integer.
|
|
254
|
+
|
|
255
|
+
***
|
|
256
|
+
|
|
257
|
+
### bigint()
|
|
258
|
+
|
|
259
|
+
> `static` **bigint**(`property`, `value`, `failures`, `fieldNameResource`?, `options`?): `value is bigint`
|
|
260
|
+
|
|
261
|
+
Is the property a bigint.
|
|
262
|
+
|
|
263
|
+
#### Parameters
|
|
264
|
+
|
|
265
|
+
• **property**: `string`
|
|
266
|
+
|
|
267
|
+
The name of the property.
|
|
268
|
+
|
|
269
|
+
• **value**: `unknown`
|
|
270
|
+
|
|
271
|
+
The value to test.
|
|
272
|
+
|
|
273
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
274
|
+
|
|
275
|
+
The list of failures to add to.
|
|
276
|
+
|
|
277
|
+
• **fieldNameResource?**: `string`
|
|
278
|
+
|
|
279
|
+
Optional i18n resource of the field name to display in the message.
|
|
280
|
+
|
|
281
|
+
• **options?**
|
|
282
|
+
|
|
283
|
+
Additional options for the validation.
|
|
284
|
+
|
|
285
|
+
• **options.minValue?**: `bigint`
|
|
286
|
+
|
|
287
|
+
The minimum value of the bigint.
|
|
288
|
+
|
|
289
|
+
• **options.maxValue?**: `bigint`
|
|
290
|
+
|
|
291
|
+
The maximum value of the bigint.
|
|
292
|
+
|
|
293
|
+
#### Returns
|
|
294
|
+
|
|
295
|
+
`value is bigint`
|
|
296
|
+
|
|
297
|
+
True if the value is a valid bigint.
|
|
298
|
+
|
|
299
|
+
***
|
|
300
|
+
|
|
301
|
+
### boolean()
|
|
302
|
+
|
|
303
|
+
> `static` **boolean**(`property`, `value`, `failures`, `fieldNameResource`?): `value is boolean`
|
|
304
|
+
|
|
305
|
+
Is the property a boolean.
|
|
306
|
+
|
|
307
|
+
#### Parameters
|
|
308
|
+
|
|
309
|
+
• **property**: `string`
|
|
310
|
+
|
|
311
|
+
The name of the property.
|
|
312
|
+
|
|
313
|
+
• **value**: `unknown`
|
|
314
|
+
|
|
315
|
+
The value to test.
|
|
316
|
+
|
|
317
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
318
|
+
|
|
319
|
+
The list of failures to add to.
|
|
320
|
+
|
|
321
|
+
• **fieldNameResource?**: `string`
|
|
322
|
+
|
|
323
|
+
Optional i18n resource of the field name to display in the message.
|
|
324
|
+
|
|
325
|
+
#### Returns
|
|
326
|
+
|
|
327
|
+
`value is boolean`
|
|
328
|
+
|
|
329
|
+
True if the value is a boolean.
|
|
330
|
+
|
|
331
|
+
***
|
|
332
|
+
|
|
333
|
+
### date()
|
|
334
|
+
|
|
335
|
+
> `static` **date**(`property`, `value`, `failures`, `fieldNameResource`?): `value is Date`
|
|
336
|
+
|
|
337
|
+
Is the property a date.
|
|
338
|
+
|
|
339
|
+
#### Parameters
|
|
340
|
+
|
|
341
|
+
• **property**: `string`
|
|
342
|
+
|
|
343
|
+
The name of the property.
|
|
344
|
+
|
|
345
|
+
• **value**: `unknown`
|
|
346
|
+
|
|
347
|
+
The value to test.
|
|
348
|
+
|
|
349
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
350
|
+
|
|
351
|
+
The list of failures to add to.
|
|
352
|
+
|
|
353
|
+
• **fieldNameResource?**: `string`
|
|
354
|
+
|
|
355
|
+
Optional i18n resource of the field name to display in the message.
|
|
356
|
+
|
|
357
|
+
#### Returns
|
|
358
|
+
|
|
359
|
+
`value is Date`
|
|
360
|
+
|
|
361
|
+
True if the value is a date.
|
|
362
|
+
|
|
363
|
+
***
|
|
364
|
+
|
|
365
|
+
### dateString()
|
|
366
|
+
|
|
367
|
+
> `static` **dateString**(`property`, `value`, `failures`, `fieldNameResource`?): `value is string`
|
|
368
|
+
|
|
369
|
+
Is the property a date in ISO 8601 format.
|
|
370
|
+
|
|
371
|
+
#### Parameters
|
|
372
|
+
|
|
373
|
+
• **property**: `string`
|
|
374
|
+
|
|
375
|
+
The name of the property.
|
|
376
|
+
|
|
377
|
+
• **value**: `unknown`
|
|
378
|
+
|
|
379
|
+
The value to test.
|
|
380
|
+
|
|
381
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
382
|
+
|
|
383
|
+
The list of failures to add to.
|
|
384
|
+
|
|
385
|
+
• **fieldNameResource?**: `string`
|
|
386
|
+
|
|
387
|
+
Optional i18n resource of the field name to display in the message.
|
|
388
|
+
|
|
389
|
+
#### Returns
|
|
390
|
+
|
|
391
|
+
`value is string`
|
|
392
|
+
|
|
393
|
+
True if the value is a date.
|
|
394
|
+
|
|
395
|
+
***
|
|
396
|
+
|
|
397
|
+
### dateTimeString()
|
|
398
|
+
|
|
399
|
+
> `static` **dateTimeString**(`property`, `value`, `failures`, `fieldNameResource`?): `value is string`
|
|
400
|
+
|
|
401
|
+
Is the property a date/time in ISO 8601 format.
|
|
402
|
+
|
|
403
|
+
#### Parameters
|
|
404
|
+
|
|
405
|
+
• **property**: `string`
|
|
406
|
+
|
|
407
|
+
The name of the property.
|
|
408
|
+
|
|
409
|
+
• **value**: `unknown`
|
|
410
|
+
|
|
411
|
+
The value to test.
|
|
412
|
+
|
|
413
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
414
|
+
|
|
415
|
+
The list of failures to add to.
|
|
416
|
+
|
|
417
|
+
• **fieldNameResource?**: `string`
|
|
418
|
+
|
|
419
|
+
Optional i18n resource of the field name to display in the message.
|
|
420
|
+
|
|
421
|
+
#### Returns
|
|
422
|
+
|
|
423
|
+
`value is string`
|
|
424
|
+
|
|
425
|
+
True if the value is a date/time.
|
|
426
|
+
|
|
427
|
+
***
|
|
428
|
+
|
|
429
|
+
### timeString()
|
|
430
|
+
|
|
431
|
+
> `static` **timeString**(`property`, `value`, `failures`, `fieldNameResource`?): `value is string`
|
|
432
|
+
|
|
433
|
+
Is the property a time in ISO 8601 format.
|
|
434
|
+
|
|
435
|
+
#### Parameters
|
|
436
|
+
|
|
437
|
+
• **property**: `string`
|
|
438
|
+
|
|
439
|
+
The name of the property.
|
|
440
|
+
|
|
441
|
+
• **value**: `unknown`
|
|
442
|
+
|
|
443
|
+
The value to test.
|
|
444
|
+
|
|
445
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
446
|
+
|
|
447
|
+
The list of failures to add to.
|
|
448
|
+
|
|
449
|
+
• **fieldNameResource?**: `string`
|
|
450
|
+
|
|
451
|
+
Optional i18n resource of the field name to display in the message.
|
|
452
|
+
|
|
453
|
+
#### Returns
|
|
454
|
+
|
|
455
|
+
`value is string`
|
|
456
|
+
|
|
457
|
+
True if the value is a time.
|
|
458
|
+
|
|
459
|
+
***
|
|
460
|
+
|
|
461
|
+
### timestampMilliseconds()
|
|
462
|
+
|
|
463
|
+
> `static` **timestampMilliseconds**(`property`, `value`, `failures`, `fieldNameResource`?): `value is number`
|
|
464
|
+
|
|
465
|
+
Is the property a timestamp in milliseconds.
|
|
466
|
+
|
|
467
|
+
#### Parameters
|
|
468
|
+
|
|
469
|
+
• **property**: `string`
|
|
470
|
+
|
|
471
|
+
The name of the property.
|
|
472
|
+
|
|
473
|
+
• **value**: `unknown`
|
|
474
|
+
|
|
475
|
+
The value to test.
|
|
476
|
+
|
|
477
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
478
|
+
|
|
479
|
+
The list of failures to add to.
|
|
480
|
+
|
|
481
|
+
• **fieldNameResource?**: `string`
|
|
482
|
+
|
|
483
|
+
Optional i18n resource of the field name to display in the message.
|
|
484
|
+
|
|
485
|
+
#### Returns
|
|
486
|
+
|
|
487
|
+
`value is number`
|
|
488
|
+
|
|
489
|
+
True if the value is a timestamp in milliseconds.
|
|
490
|
+
|
|
491
|
+
***
|
|
492
|
+
|
|
493
|
+
### timestampSeconds()
|
|
494
|
+
|
|
495
|
+
> `static` **timestampSeconds**(`property`, `value`, `failures`, `fieldNameResource`?): `value is number`
|
|
496
|
+
|
|
497
|
+
Is the property a timestamp in seconds.
|
|
498
|
+
|
|
499
|
+
#### Parameters
|
|
500
|
+
|
|
501
|
+
• **property**: `string`
|
|
502
|
+
|
|
503
|
+
The name of the property.
|
|
504
|
+
|
|
505
|
+
• **value**: `unknown`
|
|
506
|
+
|
|
507
|
+
The value to test.
|
|
508
|
+
|
|
509
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
510
|
+
|
|
511
|
+
The list of failures to add to.
|
|
512
|
+
|
|
513
|
+
• **fieldNameResource?**: `string`
|
|
514
|
+
|
|
515
|
+
Optional i18n resource of the field name to display in the message.
|
|
516
|
+
|
|
517
|
+
#### Returns
|
|
518
|
+
|
|
519
|
+
`value is number`
|
|
520
|
+
|
|
521
|
+
True if the value is a timestamp in seconds.
|
|
522
|
+
|
|
523
|
+
***
|
|
524
|
+
|
|
525
|
+
### object()
|
|
526
|
+
|
|
527
|
+
> `static` **object**\<`T`\>(`property`, `value`, `failures`, `fieldNameResource`?): `value is T`
|
|
528
|
+
|
|
529
|
+
Is the property an object.
|
|
530
|
+
|
|
531
|
+
#### Type Parameters
|
|
532
|
+
|
|
533
|
+
• **T** = `object`
|
|
534
|
+
|
|
535
|
+
#### Parameters
|
|
536
|
+
|
|
537
|
+
• **property**: `string`
|
|
538
|
+
|
|
539
|
+
The name of the property.
|
|
540
|
+
|
|
541
|
+
• **value**: `unknown`
|
|
542
|
+
|
|
543
|
+
The value to test.
|
|
544
|
+
|
|
545
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
546
|
+
|
|
547
|
+
The list of failures to add to.
|
|
548
|
+
|
|
549
|
+
• **fieldNameResource?**: `string`
|
|
550
|
+
|
|
551
|
+
Optional i18n resource of the field name to display in the message.
|
|
552
|
+
|
|
553
|
+
#### Returns
|
|
554
|
+
|
|
555
|
+
`value is T`
|
|
556
|
+
|
|
557
|
+
True if the value is a object.
|
|
558
|
+
|
|
559
|
+
***
|
|
560
|
+
|
|
561
|
+
### array()
|
|
562
|
+
|
|
563
|
+
> `static` **array**\<`T`\>(`property`, `value`, `failures`, `fieldNameResource`?): `value is T[]`
|
|
564
|
+
|
|
565
|
+
Is the property an array.
|
|
566
|
+
|
|
567
|
+
#### Type Parameters
|
|
568
|
+
|
|
569
|
+
• **T**
|
|
570
|
+
|
|
571
|
+
#### Parameters
|
|
572
|
+
|
|
573
|
+
• **property**: `string`
|
|
574
|
+
|
|
575
|
+
The name of the property.
|
|
576
|
+
|
|
577
|
+
• **value**: `unknown`
|
|
578
|
+
|
|
579
|
+
The value to test.
|
|
580
|
+
|
|
581
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
582
|
+
|
|
583
|
+
The list of failures to add to.
|
|
584
|
+
|
|
585
|
+
• **fieldNameResource?**: `string`
|
|
586
|
+
|
|
587
|
+
Optional i18n resource of the field name to display in the message.
|
|
588
|
+
|
|
589
|
+
#### Returns
|
|
590
|
+
|
|
591
|
+
`value is T[]`
|
|
592
|
+
|
|
593
|
+
True if the value is an array.
|
|
594
|
+
|
|
595
|
+
***
|
|
596
|
+
|
|
597
|
+
### arrayValue()
|
|
598
|
+
|
|
599
|
+
> `static` **arrayValue**\<`T`\>(`property`, `value`, `failures`, `fieldNameResource`?): `value is T[]`
|
|
600
|
+
|
|
601
|
+
Is the property an array with at least one item.
|
|
602
|
+
|
|
603
|
+
#### Type Parameters
|
|
604
|
+
|
|
605
|
+
• **T**
|
|
606
|
+
|
|
607
|
+
#### Parameters
|
|
608
|
+
|
|
609
|
+
• **property**: `string`
|
|
610
|
+
|
|
611
|
+
The name of the property.
|
|
612
|
+
|
|
613
|
+
• **value**: `unknown`
|
|
614
|
+
|
|
615
|
+
The value to test.
|
|
616
|
+
|
|
617
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
618
|
+
|
|
619
|
+
The list of failures to add to.
|
|
620
|
+
|
|
621
|
+
• **fieldNameResource?**: `string`
|
|
622
|
+
|
|
623
|
+
Optional i18n resource of the field name to display in the message.
|
|
624
|
+
|
|
625
|
+
#### Returns
|
|
626
|
+
|
|
627
|
+
`value is T[]`
|
|
628
|
+
|
|
629
|
+
True if the value is an array with at least one element.
|
|
630
|
+
|
|
631
|
+
***
|
|
632
|
+
|
|
633
|
+
### arrayOneOf()
|
|
634
|
+
|
|
635
|
+
> `static` **arrayOneOf**\<`T`\>(`property`, `value`, `options`, `failures`, `fieldNameResource`?): `value is T`
|
|
636
|
+
|
|
637
|
+
Is the property one of a list of items.
|
|
638
|
+
|
|
639
|
+
#### Type Parameters
|
|
640
|
+
|
|
641
|
+
• **T**
|
|
642
|
+
|
|
643
|
+
#### Parameters
|
|
644
|
+
|
|
645
|
+
• **property**: `string`
|
|
646
|
+
|
|
647
|
+
The name of the property.
|
|
648
|
+
|
|
649
|
+
• **value**: `T`
|
|
650
|
+
|
|
651
|
+
The value to test.
|
|
652
|
+
|
|
653
|
+
• **options**: `T`[]
|
|
654
|
+
|
|
655
|
+
The options the value must be one of.
|
|
656
|
+
|
|
657
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
658
|
+
|
|
659
|
+
The list of failures to add to.
|
|
660
|
+
|
|
661
|
+
• **fieldNameResource?**: `string`
|
|
662
|
+
|
|
663
|
+
Optional i18n resource of the field name to display in the message.
|
|
664
|
+
|
|
665
|
+
#### Returns
|
|
666
|
+
|
|
667
|
+
`value is T`
|
|
668
|
+
|
|
669
|
+
True if the value is one of the items in the options.
|
|
670
|
+
|
|
671
|
+
***
|
|
672
|
+
|
|
673
|
+
### uint8Array()
|
|
674
|
+
|
|
675
|
+
> `static` **uint8Array**(`property`, `value`, `failures`, `fieldNameResource`?): `value is Uint8Array`
|
|
676
|
+
|
|
677
|
+
Is the property a Uint8Array.
|
|
678
|
+
|
|
679
|
+
#### Parameters
|
|
680
|
+
|
|
681
|
+
• **property**: `string`
|
|
682
|
+
|
|
683
|
+
The name of the property.
|
|
684
|
+
|
|
685
|
+
• **value**: `unknown`
|
|
686
|
+
|
|
687
|
+
The value to test.
|
|
688
|
+
|
|
689
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
690
|
+
|
|
691
|
+
The list of failures to add to.
|
|
692
|
+
|
|
693
|
+
• **fieldNameResource?**: `string`
|
|
694
|
+
|
|
695
|
+
Optional i18n resource of the field name to display in the message.
|
|
696
|
+
|
|
697
|
+
#### Returns
|
|
698
|
+
|
|
699
|
+
`value is Uint8Array`
|
|
700
|
+
|
|
701
|
+
True if the value is a Uint8Array.
|
|
702
|
+
|
|
703
|
+
***
|
|
704
|
+
|
|
705
|
+
### json()
|
|
706
|
+
|
|
707
|
+
> `static` **json**(`property`, `value`, `failures`, `fieldNameResource`?): `value is string`
|
|
708
|
+
|
|
709
|
+
Is the property valid JSON.
|
|
710
|
+
|
|
711
|
+
#### Parameters
|
|
712
|
+
|
|
713
|
+
• **property**: `string`
|
|
714
|
+
|
|
715
|
+
The name of the property.
|
|
716
|
+
|
|
717
|
+
• **value**: `unknown`
|
|
718
|
+
|
|
719
|
+
The value to test.
|
|
720
|
+
|
|
721
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
722
|
+
|
|
723
|
+
The list of failures to add to.
|
|
724
|
+
|
|
725
|
+
• **fieldNameResource?**: `string`
|
|
726
|
+
|
|
727
|
+
Optional i18n resource of the field name to display in the message.
|
|
728
|
+
|
|
729
|
+
#### Returns
|
|
730
|
+
|
|
731
|
+
`value is string`
|
|
732
|
+
|
|
733
|
+
True if the value is valid JSON.
|
|
734
|
+
|
|
735
|
+
***
|
|
736
|
+
|
|
737
|
+
### email()
|
|
738
|
+
|
|
739
|
+
> `static` **email**(`property`, `value`, `failures`, `fieldNameResource`?): `value is string`
|
|
740
|
+
|
|
741
|
+
Is the property a string in e-mail format.
|
|
742
|
+
|
|
743
|
+
#### Parameters
|
|
744
|
+
|
|
745
|
+
• **property**: `string`
|
|
746
|
+
|
|
747
|
+
The name of the property.
|
|
748
|
+
|
|
749
|
+
• **value**: `unknown`
|
|
750
|
+
|
|
751
|
+
The value to test.
|
|
752
|
+
|
|
753
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
754
|
+
|
|
755
|
+
The list of failures to add to.
|
|
756
|
+
|
|
757
|
+
• **fieldNameResource?**: `string`
|
|
758
|
+
|
|
759
|
+
Optional i18n resource of the field name to display in the message.
|
|
760
|
+
|
|
761
|
+
#### Returns
|
|
762
|
+
|
|
763
|
+
`value is string`
|
|
764
|
+
|
|
765
|
+
True if the value is a valid looking e-mail.
|
|
766
|
+
|
|
767
|
+
***
|
|
768
|
+
|
|
769
|
+
### asValidationError()
|
|
770
|
+
|
|
771
|
+
> `static` **asValidationError**(`source`, `objectName`, `failures`): `void`
|
|
772
|
+
|
|
773
|
+
Throw the validation failures as a ValidationError.
|
|
774
|
+
|
|
775
|
+
#### Parameters
|
|
776
|
+
|
|
777
|
+
• **source**: `string`
|
|
778
|
+
|
|
779
|
+
The source of the error.
|
|
780
|
+
|
|
781
|
+
• **objectName**: `string`
|
|
782
|
+
|
|
783
|
+
The object that was being validated.
|
|
784
|
+
|
|
785
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
786
|
+
|
|
787
|
+
The validation failures.
|
|
788
|
+
|
|
789
|
+
#### Returns
|
|
790
|
+
|
|
791
|
+
`void`
|
|
792
|
+
|
|
793
|
+
#### Throws
|
|
794
|
+
|
|
795
|
+
ValidationError From the converted failures.
|
|
796
|
+
|
|
797
|
+
***
|
|
798
|
+
|
|
799
|
+
### toPropertyMap()
|
|
800
|
+
|
|
801
|
+
> `static` **toPropertyMap**(`failures`, `propertyMap`, `clearMap`): `void`
|
|
802
|
+
|
|
803
|
+
Map a list of failures to their properties in a map.
|
|
804
|
+
|
|
805
|
+
#### Parameters
|
|
806
|
+
|
|
807
|
+
• **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
|
|
808
|
+
|
|
809
|
+
The validation failures to combine into the map for the properties.
|
|
810
|
+
|
|
811
|
+
• **propertyMap**
|
|
812
|
+
|
|
813
|
+
The map to add the failures to.
|
|
814
|
+
|
|
815
|
+
• **clearMap**: `boolean` = `true`
|
|
816
|
+
|
|
817
|
+
Should the map be cleared before adding the failures.
|
|
818
|
+
|
|
819
|
+
#### Returns
|
|
820
|
+
|
|
821
|
+
`void`
|