defuss-runtime 1.1.0 → 1.2.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/dist/index.cjs +266 -84
- package/dist/index.d.cts +347 -36
- package/dist/index.d.mts +347 -36
- package/dist/index.mjs +263 -85
- package/package.json +10 -12
package/dist/index.d.cts
CHANGED
|
@@ -137,103 +137,284 @@ declare function waitForRef<T>(ref: {
|
|
|
137
137
|
current: T | null;
|
|
138
138
|
}, timeout: number): Promise<T>;
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
type TransformerFn<T extends any[] = any[]> = (...args: T) => any;
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
declare const asInteger: (value: any) => number;
|
|
142
|
+
/**
|
|
143
|
+
* Converts a value to a string representation.
|
|
144
|
+
* Handles various types including null, undefined, numbers, booleans, dates, regexes, arrays, and objects.
|
|
145
|
+
*
|
|
146
|
+
* @param value - The value to convert to a string.
|
|
147
|
+
* @returns The string representation of the value.
|
|
148
|
+
*/
|
|
149
|
+
declare const asString: TransformerFn;
|
|
151
150
|
|
|
152
151
|
/**
|
|
153
|
-
*
|
|
152
|
+
* Converts a value to a number representation.
|
|
153
|
+
* Handles various types including strings, dates, and numbers.
|
|
154
|
+
*
|
|
155
|
+
* @param value - The value to convert to a number.
|
|
156
|
+
* @returns The numeric representation of the value, or 0 if conversion fails.
|
|
154
157
|
*/
|
|
155
|
-
declare const
|
|
158
|
+
declare const asNumber: TransformerFn;
|
|
156
159
|
|
|
157
160
|
/**
|
|
158
|
-
*
|
|
161
|
+
* Converts a value to a boolean representation.
|
|
162
|
+
* Handles various types including strings, numbers, and existing booleans.
|
|
163
|
+
*
|
|
164
|
+
* @param value - The value to convert to a boolean.
|
|
165
|
+
* @returns The boolean representation of the value.
|
|
159
166
|
*/
|
|
160
|
-
declare const
|
|
167
|
+
declare const asBoolean: TransformerFn;
|
|
161
168
|
|
|
162
169
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
170
|
+
* Converts a value to an array representation.
|
|
171
|
+
* If the value is already an array, it applies a transformer function to each element.
|
|
172
|
+
* If the value is null or undefined, it returns an empty array.
|
|
173
|
+
* Otherwise, it applies the transformer function to the value and returns it as a single-element array.
|
|
174
|
+
*
|
|
175
|
+
* @param value - The value to convert to an array.
|
|
176
|
+
* @param transformerFn - A function to transform each element of the array.
|
|
177
|
+
* @returns An array representation of the value.
|
|
165
178
|
*/
|
|
166
|
-
declare const
|
|
179
|
+
declare const asArray: TransformerFn;
|
|
167
180
|
|
|
168
181
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
182
|
+
* Converts a value to a Date object.
|
|
183
|
+
* Handles various types including null, undefined, strings, numbers, and existing Date objects.
|
|
184
|
+
*
|
|
185
|
+
* @param value - The value to convert to a Date.
|
|
186
|
+
* @returns The Date representation of the value, or an invalid Date if conversion fails.
|
|
171
187
|
*/
|
|
172
|
-
declare const
|
|
188
|
+
declare const asDate: TransformerFn;
|
|
173
189
|
|
|
174
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Converts a value to an integer representation.
|
|
192
|
+
* Handles various types including strings, numbers, and objects.
|
|
193
|
+
*
|
|
194
|
+
* @param value - The value to convert to an integer.
|
|
195
|
+
* @returns The integer representation of the value, or 0 if conversion fails.
|
|
196
|
+
*/
|
|
197
|
+
declare const asInteger: TransformerFn;
|
|
175
198
|
|
|
176
199
|
type ValidationMessage = string | number | boolean | null | undefined;
|
|
177
200
|
type ValidationFnResult = true | ValidationMessage;
|
|
178
|
-
type ValidatorPrimitiveFn<T = unknown> = (value: T) => boolean | Promise<boolean>;
|
|
201
|
+
type ValidatorPrimitiveFn<T = unknown> = (value: T, message?: string) => boolean | string | Promise<boolean | string>;
|
|
179
202
|
interface SingleValidationResult {
|
|
180
203
|
message?: ValidationMessage;
|
|
181
204
|
isValid: boolean;
|
|
182
205
|
}
|
|
183
|
-
type ValidatorFn<T extends
|
|
184
|
-
type ValidationStep<T extends
|
|
206
|
+
type ValidatorFn<T extends any[] = any[]> = (...args: T) => boolean | string;
|
|
207
|
+
type ValidationStep<T extends any[] = any[]> = {
|
|
185
208
|
fn: ValidatorFn<T>;
|
|
186
209
|
args: T;
|
|
187
210
|
};
|
|
188
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Checks if the given value is a date and is after a specified minimum date.
|
|
214
|
+
* @param value - The date value to check.
|
|
215
|
+
* @param minDate - The minimum date to compare against.
|
|
216
|
+
* @param inclusive - If true, the value can be equal to the minDate.
|
|
217
|
+
* @param message - Optional error message to return when validation fails.
|
|
218
|
+
* @returns True if the value is a Date and is after the minDate, the message if validation fails and message is provided, false otherwise.
|
|
219
|
+
*/
|
|
220
|
+
declare const isAfter: ValidatorFn;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Checks if the given value is an array.
|
|
224
|
+
* @param value - The value to check.
|
|
225
|
+
* @param message - Optional error message to return when validation fails.
|
|
226
|
+
* @returns True if the value is an array, the message if validation fails and message is provided, false otherwise.
|
|
227
|
+
*/
|
|
189
228
|
declare const isArray: ValidatorPrimitiveFn;
|
|
190
229
|
|
|
191
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Checks if the given value is a date and is before a specified maximum date.
|
|
232
|
+
* @param value - The date value to check.
|
|
233
|
+
* @param maxDate - The maximum date to compare against.
|
|
234
|
+
* @param inclusive - If true, the value can be equal to the maxDate.
|
|
235
|
+
* @param message - Optional error message to return when validation fails.
|
|
236
|
+
* @returns True if the value is a Date and is before the maxDate, the message if validation fails and message is provided, false otherwise.
|
|
237
|
+
*/
|
|
238
|
+
declare const isBefore: ValidatorFn;
|
|
192
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Checks if the given value is a boolean.
|
|
242
|
+
* @param value - The value to check.
|
|
243
|
+
* @param message - Optional error message to return when validation fails.
|
|
244
|
+
* @returns True if the value is a boolean, the message if validation fails and message is provided, false otherwise.
|
|
245
|
+
*/
|
|
193
246
|
declare const isBoolean: ValidatorPrimitiveFn;
|
|
194
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Checks if the given value is a Date object.
|
|
250
|
+
* @param value - The value to check.
|
|
251
|
+
* @param message - Optional error message to return when validation fails.
|
|
252
|
+
* @returns True if the value is a Date object, the message if validation fails and message is provided, false otherwise.
|
|
253
|
+
*/
|
|
195
254
|
declare const isDate: ValidatorPrimitiveFn;
|
|
196
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Checks if the given value is defined (not `undefined`).
|
|
258
|
+
* @param value - The value to check.
|
|
259
|
+
* @param message - Optional error message to return when validation fails.
|
|
260
|
+
* @returns True if the value is defined, the message if validation fails and message is provided, false otherwise.
|
|
261
|
+
*/
|
|
197
262
|
declare const isDefined: ValidatorPrimitiveFn;
|
|
198
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Checks if the given value is a valid email address.
|
|
266
|
+
* Implements RFC 5322 official, @see https://emailregex.com/
|
|
267
|
+
* @param value - The value to check.
|
|
268
|
+
* @param message - Optional error message to return when validation fails.
|
|
269
|
+
* @returns True if the value is a valid email address, the message if validation fails and message is provided, false otherwise.
|
|
270
|
+
*/
|
|
199
271
|
declare const isEmail: ValidatorPrimitiveFn;
|
|
200
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Checks if the given value is empty.
|
|
275
|
+
* An empty value is defined as:
|
|
276
|
+
* - `null` or `undefined`
|
|
277
|
+
* - an empty string
|
|
278
|
+
* - an empty array
|
|
279
|
+
* - an object with no own properties
|
|
280
|
+
* - a Date object (not considered empty)
|
|
281
|
+
*
|
|
282
|
+
* @param value - The value to check.
|
|
283
|
+
* @param message - Optional error message to return when validation fails.
|
|
284
|
+
* @returns True if the value is empty, the message if validation fails and message is provided, false otherwise.
|
|
285
|
+
*/
|
|
201
286
|
declare const isEmpty: ValidatorPrimitiveFn;
|
|
202
287
|
|
|
203
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Checks if the given value is equal to another value.
|
|
290
|
+
* @param value - The first value to compare.
|
|
291
|
+
* @param valueB - The second value to compare.
|
|
292
|
+
* @param message - Optional error message to return when validation fails.
|
|
293
|
+
* @returns True if the values are equal, the message if validation fails and message is provided, false otherwise.
|
|
294
|
+
*/
|
|
295
|
+
declare const is: ValidatorFn;
|
|
204
296
|
|
|
205
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Checks if the given value is greater than a specified minimum value.
|
|
299
|
+
* Optionally includes equality in the comparison.
|
|
300
|
+
*
|
|
301
|
+
* @param value - The value to check.
|
|
302
|
+
* @param minValue - The minimum value to compare against.
|
|
303
|
+
* @param includeEqual - Whether to include equality in the comparison (default: false).
|
|
304
|
+
* @param message - Optional error message to return when validation fails.
|
|
305
|
+
* @returns True if the value is greater than (or equal to, if `includeEqual` is true) the minimum value, the message if validation fails and message is provided, false otherwise.
|
|
306
|
+
*/
|
|
307
|
+
declare const isGreaterThan: ValidatorFn;
|
|
206
308
|
|
|
207
309
|
/**
|
|
208
310
|
* Checks if a value is a safe number (not NaN and finite).
|
|
209
311
|
* @param value - The value to check
|
|
210
|
-
* @
|
|
312
|
+
* @param message - Optional error message to return when validation fails.
|
|
313
|
+
* @returns True if the value is a safe number, the message if validation fails and message is provided, false otherwise
|
|
211
314
|
*/
|
|
212
315
|
declare const isSafeNumber: ValidatorPrimitiveFn;
|
|
213
316
|
|
|
214
317
|
/**
|
|
215
318
|
* Checks if a value (number or string) is a numeric and a safe number.
|
|
216
319
|
* @param value - The value to check
|
|
217
|
-
* @
|
|
320
|
+
* @param message - Optional error message to return when validation fails.
|
|
321
|
+
* @returns True if the value is numeric, the message if validation fails and message is provided, false otherwise
|
|
218
322
|
*/
|
|
219
323
|
declare const isSafeNumeric: ValidatorPrimitiveFn;
|
|
220
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Checks if the provided value is an object.
|
|
327
|
+
* An object is defined as a non-null value that is of type 'object' and not an array.
|
|
328
|
+
*
|
|
329
|
+
* @param value - The value to check if it is an object.
|
|
330
|
+
* @param message - Optional error message to return when validation fails.
|
|
331
|
+
* @returns True if the value is an object, the message if validation fails and message is provided, false otherwise.
|
|
332
|
+
*/
|
|
221
333
|
declare const isObject: ValidatorPrimitiveFn;
|
|
222
334
|
|
|
223
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Checks if the given value is one of the specified options.
|
|
337
|
+
* This function checks if the value is included in the provided array of options.
|
|
338
|
+
*
|
|
339
|
+
* @param value - The value to check.
|
|
340
|
+
* @param options - An array of strings or numbers to check against.
|
|
341
|
+
* @param message - Optional error message to return when validation fails.
|
|
342
|
+
* @returns True if the value is one of the options, the message if validation fails and message is provided, false otherwise.
|
|
343
|
+
*/
|
|
344
|
+
declare const isOneOf: ValidatorFn;
|
|
224
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Validates if the provided value is a valid phone number.
|
|
348
|
+
* The phone number must be a string that matches the E.164 format.
|
|
349
|
+
*
|
|
350
|
+
* @param value - The value to validate as a phone number.
|
|
351
|
+
* @param message - Optional error message to return when validation fails.
|
|
352
|
+
* @returns True if the value is a valid phone number, the message if validation fails and message is provided, false otherwise.
|
|
353
|
+
*/
|
|
225
354
|
declare const isPhoneNumber: ValidatorPrimitiveFn;
|
|
226
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Checks if the provided value is required.
|
|
358
|
+
* This function checks if the value is truthy, meaning it is not null, undefined, or an empty string.
|
|
359
|
+
*
|
|
360
|
+
* @param value - The value to check if it is required.
|
|
361
|
+
* @param message - Optional error message to return when validation fails.
|
|
362
|
+
* @returns True if the value is required (truthy), the message if validation fails and message is provided, false otherwise.
|
|
363
|
+
*/
|
|
227
364
|
declare const isRequired: ValidatorPrimitiveFn;
|
|
228
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Validates if the provided value is a valid slug.
|
|
368
|
+
* A slug is a string that consists of lowercase letters, numbers, and hyphens.
|
|
369
|
+
* It does not allow spaces or special characters.
|
|
370
|
+
*
|
|
371
|
+
* @param value - The value to validate as a slug.
|
|
372
|
+
* @param message - Optional error message to return when validation fails.
|
|
373
|
+
* @returns True if the value is a valid slug, the message if validation fails and message is provided, false otherwise.
|
|
374
|
+
*/
|
|
229
375
|
declare const isSlug: ValidatorPrimitiveFn;
|
|
230
376
|
|
|
231
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Checks if the given value is less than a specified maximum value.
|
|
379
|
+
* Optionally includes equality in the comparison.
|
|
380
|
+
*
|
|
381
|
+
* @param value - The value to check.
|
|
382
|
+
* @param maxValue - The maximum value to compare against.
|
|
383
|
+
* @param includeEqual - Whether to include equality in the comparison (default: false).
|
|
384
|
+
* @param message - Optional error message to return when validation fails.
|
|
385
|
+
* @returns True if the value is less than (or equal to, if `includeEqual` is true) the maximum value, the message if validation fails and message is provided, false otherwise.
|
|
386
|
+
*/
|
|
387
|
+
declare const isLessThan: ValidatorFn;
|
|
232
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Validates if the provided value is a string.
|
|
391
|
+
* This function checks if the value is of type string.
|
|
392
|
+
*
|
|
393
|
+
* @param value - The value to validate as a string.
|
|
394
|
+
* @param message - Optional error message to return when validation fails.
|
|
395
|
+
* @returns True if the value is a string, the message if validation fails and message is provided, false otherwise.
|
|
396
|
+
*/
|
|
233
397
|
declare const isString: ValidatorPrimitiveFn;
|
|
234
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Validates if the provided value is a valid URL.
|
|
401
|
+
* The URL must be a string that can be parsed by the URL constructor.
|
|
402
|
+
*
|
|
403
|
+
* @param value - The value to validate as a URL.
|
|
404
|
+
* @param message - Optional error message to return when validation fails.
|
|
405
|
+
* @returns True if the value is a valid URL, the message if validation fails and message is provided, false otherwise.
|
|
406
|
+
*/
|
|
235
407
|
declare const isUrl: ValidatorPrimitiveFn;
|
|
236
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Validates if the provided value is a valid URL path.
|
|
411
|
+
* A URL path consists of lowercase letters, numbers, hyphens, underscores, and slashes.
|
|
412
|
+
* It does not allow spaces or special characters.
|
|
413
|
+
*
|
|
414
|
+
* @param value - The value to validate as a URL path.
|
|
415
|
+
* @param message - Optional error message to return when validation fails.
|
|
416
|
+
* @returns True if the value is a valid URL path, the message if validation fails and message is provided, false otherwise.
|
|
417
|
+
*/
|
|
237
418
|
declare const isUrlPath: ValidatorPrimitiveFn;
|
|
238
419
|
|
|
239
420
|
interface DateValue {
|
|
@@ -245,19 +426,149 @@ interface DateValue {
|
|
|
245
426
|
second: number;
|
|
246
427
|
millisecond: number;
|
|
247
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Converts a Date object into a DateValue object.
|
|
431
|
+
* @param date - The Date object to convert.
|
|
432
|
+
* @returns A DateValue object containing the year, month, date, hour, minute, second, and millisecond.
|
|
433
|
+
*/
|
|
248
434
|
declare const getDateValue: (date: Date) => DateValue;
|
|
249
435
|
|
|
250
|
-
|
|
436
|
+
/**
|
|
437
|
+
* Checks if the given value is a string and its length is longer than a specified minimum length.
|
|
438
|
+
* Optionally, it can include equality in the comparison.
|
|
439
|
+
*
|
|
440
|
+
* @param value - The value to check.
|
|
441
|
+
* @param minLength - The minimum length to compare against.
|
|
442
|
+
* @param includeEqual - Whether to include equality in the comparison (default: false).
|
|
443
|
+
* @param message - Optional error message to return when validation fails.
|
|
444
|
+
* @returns True if the value is a string and its length is longer than the specified minimum length,
|
|
445
|
+
* the message if validation fails and message is provided, false otherwise.
|
|
446
|
+
*/
|
|
447
|
+
declare const isLongerThan: ValidatorFn;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Checks if the given value is shorter than a specified maximum length.
|
|
451
|
+
* Optionally includes equality in the comparison.
|
|
452
|
+
*
|
|
453
|
+
* @param value - The value to check, expected to be a string.
|
|
454
|
+
* @param maxLength - The maximum length to compare against.
|
|
455
|
+
* @param includeEqual - If true, includes equality in the comparison (default is false).
|
|
456
|
+
* @param message - Optional error message to return when validation fails.
|
|
457
|
+
* @returns True if the value's length is shorter than (or equal to, if includeEqual is true) the maxLength, the message if validation fails and message is provided, false otherwise.
|
|
458
|
+
*/
|
|
459
|
+
declare const isShorterThan: ValidatorFn;
|
|
251
460
|
|
|
252
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Checks if the given value matches a specified pattern.
|
|
463
|
+
* @param value - The value to check.
|
|
464
|
+
* @param pattern - The regular expression pattern to match against.
|
|
465
|
+
* @param message - Optional error message to return when validation fails.
|
|
466
|
+
* @returns True if the value matches the pattern, the message if validation fails and message is provided, false otherwise.
|
|
467
|
+
*/
|
|
468
|
+
declare const hasPattern: ValidatorFn;
|
|
253
469
|
|
|
254
|
-
|
|
470
|
+
/**
|
|
471
|
+
* Checks if the given value is a valid/parsable date format.
|
|
472
|
+
* @param value - The value to check.
|
|
473
|
+
* @param message - Optional error message to return when validation fails.
|
|
474
|
+
* @returns True if the value is a valid date format, the message if validation fails and message is provided, false otherwise.
|
|
475
|
+
*/
|
|
476
|
+
declare const hasDateFormat: ValidatorFn;
|
|
255
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Checks if the given value is an integer.
|
|
480
|
+
* An integer is a number without a fractional part.
|
|
481
|
+
*
|
|
482
|
+
* @param value - The value to check.
|
|
483
|
+
* @param message - Optional error message to return when validation fails.
|
|
484
|
+
* @returns True if the value is an integer, the message if validation fails and message is provided, false otherwise.
|
|
485
|
+
*/
|
|
256
486
|
declare const isInteger: ValidatorPrimitiveFn;
|
|
257
487
|
|
|
258
|
-
|
|
488
|
+
/**
|
|
489
|
+
* Compares two values for equality using a deep comparison.
|
|
490
|
+
* This function checks if the two values are equal in terms of their JSON representation.
|
|
491
|
+
*
|
|
492
|
+
* @param value - The first value to compare.
|
|
493
|
+
* @param valueB - The second value to compare.
|
|
494
|
+
* @param message - Optional error message to return when validation fails.
|
|
495
|
+
* @returns True if the values are equal, the message if validation fails and message is provided, false otherwise.
|
|
496
|
+
*/
|
|
497
|
+
declare const isEqual: ValidatorFn;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Transformer that checks if a value is strictly true.
|
|
501
|
+
* @param value - The value to check.
|
|
502
|
+
* @param message - Optional error message to return when validation fails.
|
|
503
|
+
* @returns True if the value is strictly true, the message if validation fails and message is provided, false otherwise.
|
|
504
|
+
*/
|
|
505
|
+
declare const isTrue: ValidatorFn;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Transformer that checks if a value is strictly false.
|
|
509
|
+
* @param value - The value to check.
|
|
510
|
+
* @param message - Optional error message to return when validation fails.
|
|
511
|
+
* @returns True if the value is strictly false, the message if validation fails and message is provided, false otherwise.
|
|
512
|
+
*/
|
|
513
|
+
declare const isFalse: ValidatorFn;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Transformer that checks if a value is truthy.
|
|
517
|
+
* Returns true for all truthy values (non-zero numbers, non-empty strings, objects, etc.)
|
|
518
|
+
* @param value - The value to check.
|
|
519
|
+
* @param message - Optional error message to return when validation fails.
|
|
520
|
+
* @returns True if the value is truthy, the message if validation fails and message is provided, false otherwise.
|
|
521
|
+
*/
|
|
522
|
+
declare const isTruthy: ValidatorFn;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Transformer that checks if a value is falsy.
|
|
526
|
+
* Returns true for all falsy values (false, 0, "", null, undefined, NaN)
|
|
527
|
+
* @param value - The value to check.
|
|
528
|
+
* @param message - Optional error message to return when validation fails.
|
|
529
|
+
* @returns True if the value is falsy, the message if validation fails and message is provided, false otherwise.
|
|
530
|
+
*/
|
|
531
|
+
declare const isFalsy: ValidatorFn;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Checks if the given value is an instance of a specified constructor function.
|
|
535
|
+
* This function verifies that the value is an instance of the provided constructor
|
|
536
|
+
* and that its constructor matches the specified constructor.
|
|
537
|
+
*
|
|
538
|
+
* @param value - The value to check.
|
|
539
|
+
* @param someConstructorFunction - The constructor function to check against.
|
|
540
|
+
* @param message - Optional error message to return when validation fails.
|
|
541
|
+
* @returns True if the value is an instance of the constructor, the message if validation fails and message is provided, false otherwise.
|
|
542
|
+
* @throws TypeError if `someConstructorFunction` is not a function.
|
|
543
|
+
*/
|
|
544
|
+
declare const isInstanceOf: ValidatorFn;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Checks if the provided value is of a specific type.
|
|
548
|
+
* This function checks if the value matches the specified type, which can be one of:
|
|
549
|
+
* - "string"
|
|
550
|
+
* - "number"
|
|
551
|
+
* - "boolean"
|
|
552
|
+
* - "object"
|
|
553
|
+
* - "function"
|
|
554
|
+
* - "undefined"
|
|
555
|
+
*
|
|
556
|
+
* @param value - The value to check its type.
|
|
557
|
+
* @param type - The type to check against.
|
|
558
|
+
* @param message - Optional error message to return when validation fails.
|
|
559
|
+
* @returns True if the value is of the specified type, the message if validation fails and message is provided, false otherwise.
|
|
560
|
+
*/
|
|
561
|
+
declare const isTypeOf: ValidatorFn;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Checks if the provided value is null.
|
|
565
|
+
* @param value any - The value to check if it is null.
|
|
566
|
+
* @param message - Optional error message to return when validation fails.
|
|
567
|
+
* @returns boolean | string - Returns true if the value is null, the message if validation fails and message is provided, false otherwise.
|
|
568
|
+
*/
|
|
569
|
+
declare const isNull: ValidatorPrimitiveFn;
|
|
259
570
|
|
|
260
571
|
type PreloadAs = "image" | "script" | "style" | "fetch" | "track" | "font";
|
|
261
572
|
declare function preload(url: string | string[], as?: PreloadAs): void;
|
|
262
573
|
|
|
263
|
-
export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type PreloadAs, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isFalse, isFalsy, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isTrue, isTruthy, isUrl, isUrlPath, omit, pick, preload, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
|
|
574
|
+
export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type PreloadAs, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasDateFormat, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isFalse, isFalsy, isGreaterThan, isInstanceOf, isInteger, isLessThan, isLongerThan, isNull, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isTrue, isTruthy, isTypeOf, isUrl, isUrlPath, omit, pick, preload, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
|