validator-fns 2.2.0 → 3.0.0-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/dist/index.d.cts CHANGED
@@ -1,11 +1,6 @@
1
1
  //#region src/shared.d.ts
2
2
  type ValidResult<T> = {
3
- /**
4
- * True if the original value is valid according to all validation tests
5
- * @deprecated Use `state` instead.
6
- */
7
- isValid: true;
8
- /** This is preferred to use over `isValid` as it works better for type guards. */
3
+ /** `valid` if the value passed every validation test. */
9
4
  state: 'valid';
10
5
  /** The parsed value. Note that may be different than the original value. */
11
6
  value: T | null | undefined;
@@ -13,12 +8,7 @@ type ValidResult<T> = {
13
8
  field?: string | undefined;
14
9
  };
15
10
  type InvalidResult<E> = {
16
- /**
17
- * True if the original value is valid according to all validation tests.
18
- * @deprecated Use `state` instead.
19
- */
20
- isValid: false;
21
- /** This is preferred to use over `isValid` as it works better for type guards. */
11
+ /** `invalid` if the value failed a validation test. */
22
12
  state: 'invalid';
23
13
  /** The parsed value. Note that may be different than the original value. */
24
14
  value: unknown;
@@ -34,19 +24,19 @@ type InvalidResult<E> = {
34
24
  * @typeParam T The value type
35
25
  * @category Types
36
26
  */
37
- type ValidatorResult<T = any, E = any> = ValidResult<T> | InvalidResult<E>;
27
+ type ValidatorResult<T = unknown, E = unknown> = ValidResult<T> | InvalidResult<E>;
38
28
  /**
39
29
  * Validation test function.
40
30
  * @typeParam T The value type
41
31
  * @category Types
42
32
  */
43
- type ValidatorTest<T = any, E = any> = (value?: unknown, field?: string) => Promise<ValidatorResult<T, E>>;
33
+ type ValidatorTest<T = unknown, E = unknown> = (value?: unknown, field?: string) => Promise<ValidatorResult<T, E>>;
44
34
  /**
45
35
  * Extracts the generic error type from a ValidatorTest.
46
36
  * @typeParam T a ValidatorTest
47
37
  * @category Types
48
38
  */
49
- type ExtractError<T extends ValidatorTest> = T extends ValidatorTest<any, infer E> ? E : unknown;
39
+ type ExtractError<T extends ValidatorTest> = T extends ValidatorTest<unknown, infer E> ? E : unknown;
50
40
  /**
51
41
  * Extracts the generic value type from a ValidatorTest.
52
42
  * @typeParam T a ValidatorTest
@@ -64,7 +54,7 @@ type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
64
54
  * @typeParam C The configuration type
65
55
  * @category Types
66
56
  */
67
- type ValidatorFactory<C, T, E> = (config?: Partial<C> | ValidatorTest, ...tests: ValidatorTest[]) => ValidatorTest<T, E>;
57
+ type ValidatorFactory<C, T, E> = (config?: Partial<C> | ValidatorTest<unknown, E>, ...tests: ValidatorTest<unknown, E>[]) => ValidatorTest<T, E>;
68
58
  /**
69
59
  * Base configuration type.
70
60
  * @typeParam T The target type.
@@ -125,7 +115,7 @@ export declare function valid<T, E = never>(result: {
125
115
  * @param result.extras Extra message params
126
116
  * @category Helpers
127
117
  */
128
- export declare function invalid<T, E, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(result: {
118
+ export declare function invalid<T, E = never, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(result: {
129
119
  message: ValidatorMessage<T, P>;
130
120
  value: unknown;
131
121
  field: string | undefined;
@@ -156,7 +146,7 @@ export declare function parseArray(value: unknown): unknown[] | null | undefined
156
146
  * @param config Configuration to apply
157
147
  * @category Helpers
158
148
  */
159
- export declare function applyArrayConfig<T>(config: ArrayConfig, value: unknown): T[] | null | undefined;
149
+ export declare function applyArrayConfig(config: ArrayConfig, value: unknown): unknown[] | null | undefined;
160
150
  /**
161
151
  * Validates an array. The first passed validator is used to validate individual
162
152
  * items. The remaining validators target the array itself.
@@ -210,7 +200,7 @@ interface MinDateValidatorMessageParameters extends ValidatorMessageParameters<D
210
200
  * @param exclusive Makes comparison exclusive instead of inclusive
211
201
  * @category Validation Tests
212
202
  */
213
- export declare function minDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MinDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, null>;
203
+ export declare function minDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MinDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, never>;
214
204
  interface MaxDateValidatorMessageParameters extends ValidatorMessageParameters<Date> {
215
205
  max: Date | null | undefined;
216
206
  limit: Date | null | undefined;
@@ -223,7 +213,7 @@ interface MaxDateValidatorMessageParameters extends ValidatorMessageParameters<D
223
213
  * @param exclusive Makes comparison exclusive instead of inclusive
224
214
  * @category Validation Tests
225
215
  */
226
- export declare function maxDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MaxDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date>;
216
+ export declare function maxDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MaxDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, never>;
227
217
  /**
228
218
  * Configuration for date validation.
229
219
  * @category Types
@@ -254,7 +244,7 @@ export declare function applyNumberConfig(value: unknown, config: NumberConfig):
254
244
  * @param message Error message
255
245
  * @category Validation Tests
256
246
  */
257
- export declare function integer(message: ValidatorMessage<number>): ValidatorTest<number>;
247
+ export declare function integer(message: ValidatorMessage<number>): ValidatorTest<number, never>;
258
248
  /**
259
249
  * Configuration for number validation.
260
250
  * @category Types
@@ -292,9 +282,9 @@ export declare function check<T, E = never>(test: (value: T) => boolean, message
292
282
  export declare function check<T, E = never>(path: string | readonly string[], test: (value: T) => boolean, message: ValidatorMessage<T>): ValidatorTest<T, E>;
293
283
  //#endregion
294
284
  //#region src/objects.d.ts
295
- type ObjectParameter = Record<string, ValidatorTest<unknown, unknown>>;
285
+ type ObjectParameter = Record<string, ValidatorTest>;
296
286
  /** @internal */
297
- type ObjectValue<P extends ObjectParameter> = { [K in keyof P]?: ExtractValue<P[K]>; };
287
+ type ObjectValue<P extends ObjectParameter> = { [K in keyof P]?: ExtractValue<P[K]> | null; };
298
288
  /** @internal */
299
289
  type ObjectErrors<P extends ObjectParameter> = { [K in keyof P]?: ExtractError<P[K]>; };
300
290
  /**
@@ -430,7 +420,7 @@ export declare function standard<T, E>(validator: ValidatorTest<T, E>): Validato
430
420
  * @param nullable Allow null values
431
421
  * @category Validation Tests
432
422
  */
433
- export declare function required<T, P extends ValidatorMessageParameters<T>>(message: ValidatorMessage<T, P>, nullable?: boolean): ValidatorTest<T>;
423
+ export declare function required<T, P extends ValidatorMessageParameters<T>>(message: ValidatorMessage<T, P>, nullable?: boolean): ValidatorTest<T, never>;
434
424
  interface OneOfValidatorMessageParameters<T> extends ValidatorMessageParameters<T> {
435
425
  values: readonly T[];
436
426
  }
@@ -440,7 +430,7 @@ interface OneOfValidatorMessageParameters<T> extends ValidatorMessageParameters<
440
430
  * @param message Error message
441
431
  * @category Validation Tests
442
432
  */
443
- export declare function oneOf<T extends string | number | boolean | Date>(values: readonly T[], message: ValidatorMessage<T, OneOfValidatorMessageParameters<T>>): ValidatorTest<T>;
433
+ export declare function oneOf<T extends string | number | boolean | Date>(values: readonly T[], message: ValidatorMessage<T, OneOfValidatorMessageParameters<T>>): ValidatorTest<T, never>;
444
434
  //#endregion
445
435
  //#region src/factories.d.ts
446
436
  /**
@@ -451,14 +441,14 @@ export declare function oneOf<T extends string | number | boolean | Date>(values
451
441
  * @param applyConfig Function that applies configuration to value.
452
442
  * @category Helpers
453
443
  */
454
- export declare function createTypeValidatorTest<T, C extends ConfigBase<T>>(defaultConfig: C, applyConfig: (value: unknown, config: C) => T | null | undefined): ValidatorFactory<C, T, string>;
444
+ export declare function createTypeValidatorTest<T, C extends ConfigBase<T>>(defaultConfig: NoInfer<C>, applyConfig: (value: unknown, config: C) => T | null | undefined): ValidatorFactory<C, T, string>;
455
445
  /**
456
446
  * Captures basic validator test pattern
457
447
  * @param test Test function
458
448
  * @param message Error message
459
449
  * @param getExtras Optional extra fields for error message
460
450
  */
461
- export declare function createValidatorTest<T = any, E = any, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(test: (value: unknown, field?: string) => boolean, message: ValidatorMessage<T, P>, getExtras?: (value: T | null | undefined) => Omit<P, 'value' | 'field'>): ValidatorTest<T, E>;
451
+ export declare function createValidatorTest<T = unknown, E = never, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(test: (value: unknown, field?: string) => boolean, message: ValidatorMessage<T, P>, getExtras?: (value: T | null | undefined) => Omit<P, 'value' | 'field'>): ValidatorTest<T, E>;
462
452
  //#endregion
463
453
  //#region src/limits.d.ts
464
454
  type SharedValueType = string | number | unknown[];
@@ -475,7 +465,7 @@ interface MaxValidatorMessageParameters extends ValidatorMessageParameters<Share
475
465
  * @param exclusive Use exclusive comparison instead of inclusive
476
466
  * @category Validation Tests
477
467
  */
478
- export declare function max(limit: number, message: ValidatorMessage<SharedValueType, MaxValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType>;
468
+ export declare function max(limit: number, message: ValidatorMessage<SharedValueType, MaxValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType, never>;
479
469
  interface MinValidatorMessageParameters extends ValidatorMessageParameters<SharedValueType> {
480
470
  min: number;
481
471
  limit: number;
@@ -489,7 +479,7 @@ interface MinValidatorMessageParameters extends ValidatorMessageParameters<Share
489
479
  * @param exclusive Use exclusive comparison instead of inclusive
490
480
  * @category Validation Tests
491
481
  */
492
- export declare function min(limit: number, message: ValidatorMessage<SharedValueType, MinValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType>;
482
+ export declare function min(limit: number, message: ValidatorMessage<SharedValueType, MinValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType, never>;
493
483
  interface ExactValidatorMessageParameters extends ValidatorMessageParameters<SharedValueType> {
494
484
  limit: number;
495
485
  amount: number | null | undefined;
@@ -501,7 +491,7 @@ interface ExactValidatorMessageParameters extends ValidatorMessageParameters<Sha
501
491
  * @param message Error message
502
492
  * @category Validation Tests
503
493
  */
504
- export declare function exact(limit: number, message: ValidatorMessage<SharedValueType, ExactValidatorMessageParameters>): ValidatorTest<SharedValueType>;
494
+ export declare function exact(limit: number, message: ValidatorMessage<SharedValueType, ExactValidatorMessageParameters>): ValidatorTest<SharedValueType, never>;
505
495
  //#endregion
506
496
  //#region src/strings.d.ts
507
497
  /**
@@ -534,28 +524,28 @@ interface MatchesValidatorMessageParameters extends ValidatorMessageParameters<s
534
524
  * @param message Error message
535
525
  * @category Validation Tests
536
526
  */
537
- export declare function matches(pattern: RegExp, message: ValidatorMessage<string, MatchesValidatorMessageParameters>): ValidatorTest<string>;
527
+ export declare function matches(pattern: RegExp, message: ValidatorMessage<string, MatchesValidatorMessageParameters>): ValidatorTest<string, never>;
538
528
  /**
539
529
  * Ensures a string value matches an email pattern
540
530
  * @param message Error message
541
531
  * @category Validation Tests
542
532
  */
543
- export declare function email(message: ValidatorMessage<string>): ValidatorTest<string>;
533
+ export declare function email(message: ValidatorMessage<string>): ValidatorTest<string, never>;
544
534
  /**
545
535
  * Ensures a string value is an RFC 9562 UUID, any version from 1 to 8, or the
546
536
  * nil or max UUID. Case-insensitive, without braces or a `urn:uuid:` prefix.
547
537
  * @param message Error message
548
538
  * @category Validation Tests
549
539
  */
550
- export declare function uuid(message: ValidatorMessage<string>): ValidatorTest<string>;
540
+ export declare function uuid(message: ValidatorMessage<string>): ValidatorTest<string, never>;
551
541
  /**
552
542
  * Ensures a string value is a valid URL
553
543
  * @param message Error message
554
- * @param protocols Optional list of protocols to allow. Without it, `javascript:`
555
- * and `data:` URLs are valid; use `['http:', 'https:']` for values rendered as links.
544
+ * @param protocols Protocols to allow. Defaults to `['http:', 'https:']`; a list
545
+ * replaces the default.
556
546
  * @category Validation Tests
557
547
  */
558
- export declare function url(message: ValidatorMessage<string>, protocols?: string[]): ValidatorTest<string>;
548
+ export declare function url(message: ValidatorMessage<string>, protocols?: string[]): ValidatorTest<string, never>;
559
549
  /**
560
550
  * Validates a string value.
561
551
  * @category Type Validators
package/dist/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  //#region src/shared.d.ts
2
2
  type ValidResult<T> = {
3
- /**
4
- * True if the original value is valid according to all validation tests
5
- * @deprecated Use `state` instead.
6
- */
7
- isValid: true;
8
- /** This is preferred to use over `isValid` as it works better for type guards. */
3
+ /** `valid` if the value passed every validation test. */
9
4
  state: 'valid';
10
5
  /** The parsed value. Note that may be different than the original value. */
11
6
  value: T | null | undefined;
@@ -13,12 +8,7 @@ type ValidResult<T> = {
13
8
  field?: string | undefined;
14
9
  };
15
10
  type InvalidResult<E> = {
16
- /**
17
- * True if the original value is valid according to all validation tests.
18
- * @deprecated Use `state` instead.
19
- */
20
- isValid: false;
21
- /** This is preferred to use over `isValid` as it works better for type guards. */
11
+ /** `invalid` if the value failed a validation test. */
22
12
  state: 'invalid';
23
13
  /** The parsed value. Note that may be different than the original value. */
24
14
  value: unknown;
@@ -34,19 +24,19 @@ type InvalidResult<E> = {
34
24
  * @typeParam T The value type
35
25
  * @category Types
36
26
  */
37
- type ValidatorResult<T = any, E = any> = ValidResult<T> | InvalidResult<E>;
27
+ type ValidatorResult<T = unknown, E = unknown> = ValidResult<T> | InvalidResult<E>;
38
28
  /**
39
29
  * Validation test function.
40
30
  * @typeParam T The value type
41
31
  * @category Types
42
32
  */
43
- type ValidatorTest<T = any, E = any> = (value?: unknown, field?: string) => Promise<ValidatorResult<T, E>>;
33
+ type ValidatorTest<T = unknown, E = unknown> = (value?: unknown, field?: string) => Promise<ValidatorResult<T, E>>;
44
34
  /**
45
35
  * Extracts the generic error type from a ValidatorTest.
46
36
  * @typeParam T a ValidatorTest
47
37
  * @category Types
48
38
  */
49
- type ExtractError<T extends ValidatorTest> = T extends ValidatorTest<any, infer E> ? E : unknown;
39
+ type ExtractError<T extends ValidatorTest> = T extends ValidatorTest<unknown, infer E> ? E : unknown;
50
40
  /**
51
41
  * Extracts the generic value type from a ValidatorTest.
52
42
  * @typeParam T a ValidatorTest
@@ -64,7 +54,7 @@ type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
64
54
  * @typeParam C The configuration type
65
55
  * @category Types
66
56
  */
67
- type ValidatorFactory<C, T, E> = (config?: Partial<C> | ValidatorTest, ...tests: ValidatorTest[]) => ValidatorTest<T, E>;
57
+ type ValidatorFactory<C, T, E> = (config?: Partial<C> | ValidatorTest<unknown, E>, ...tests: ValidatorTest<unknown, E>[]) => ValidatorTest<T, E>;
68
58
  /**
69
59
  * Base configuration type.
70
60
  * @typeParam T The target type.
@@ -125,7 +115,7 @@ export declare function valid<T, E = never>(result: {
125
115
  * @param result.extras Extra message params
126
116
  * @category Helpers
127
117
  */
128
- export declare function invalid<T, E, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(result: {
118
+ export declare function invalid<T, E = never, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(result: {
129
119
  message: ValidatorMessage<T, P>;
130
120
  value: unknown;
131
121
  field: string | undefined;
@@ -156,7 +146,7 @@ export declare function parseArray(value: unknown): unknown[] | null | undefined
156
146
  * @param config Configuration to apply
157
147
  * @category Helpers
158
148
  */
159
- export declare function applyArrayConfig<T>(config: ArrayConfig, value: unknown): T[] | null | undefined;
149
+ export declare function applyArrayConfig(config: ArrayConfig, value: unknown): unknown[] | null | undefined;
160
150
  /**
161
151
  * Validates an array. The first passed validator is used to validate individual
162
152
  * items. The remaining validators target the array itself.
@@ -210,7 +200,7 @@ interface MinDateValidatorMessageParameters extends ValidatorMessageParameters<D
210
200
  * @param exclusive Makes comparison exclusive instead of inclusive
211
201
  * @category Validation Tests
212
202
  */
213
- export declare function minDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MinDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, null>;
203
+ export declare function minDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MinDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, never>;
214
204
  interface MaxDateValidatorMessageParameters extends ValidatorMessageParameters<Date> {
215
205
  max: Date | null | undefined;
216
206
  limit: Date | null | undefined;
@@ -223,7 +213,7 @@ interface MaxDateValidatorMessageParameters extends ValidatorMessageParameters<D
223
213
  * @param exclusive Makes comparison exclusive instead of inclusive
224
214
  * @category Validation Tests
225
215
  */
226
- export declare function maxDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MaxDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date>;
216
+ export declare function maxDate(limit: SharedDateValueType, message: ValidatorMessage<Date, MaxDateValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<Date, never>;
227
217
  /**
228
218
  * Configuration for date validation.
229
219
  * @category Types
@@ -254,7 +244,7 @@ export declare function applyNumberConfig(value: unknown, config: NumberConfig):
254
244
  * @param message Error message
255
245
  * @category Validation Tests
256
246
  */
257
- export declare function integer(message: ValidatorMessage<number>): ValidatorTest<number>;
247
+ export declare function integer(message: ValidatorMessage<number>): ValidatorTest<number, never>;
258
248
  /**
259
249
  * Configuration for number validation.
260
250
  * @category Types
@@ -292,9 +282,9 @@ export declare function check<T, E = never>(test: (value: T) => boolean, message
292
282
  export declare function check<T, E = never>(path: string | readonly string[], test: (value: T) => boolean, message: ValidatorMessage<T>): ValidatorTest<T, E>;
293
283
  //#endregion
294
284
  //#region src/objects.d.ts
295
- type ObjectParameter = Record<string, ValidatorTest<unknown, unknown>>;
285
+ type ObjectParameter = Record<string, ValidatorTest>;
296
286
  /** @internal */
297
- type ObjectValue<P extends ObjectParameter> = { [K in keyof P]?: ExtractValue<P[K]>; };
287
+ type ObjectValue<P extends ObjectParameter> = { [K in keyof P]?: ExtractValue<P[K]> | null; };
298
288
  /** @internal */
299
289
  type ObjectErrors<P extends ObjectParameter> = { [K in keyof P]?: ExtractError<P[K]>; };
300
290
  /**
@@ -430,7 +420,7 @@ export declare function standard<T, E>(validator: ValidatorTest<T, E>): Validato
430
420
  * @param nullable Allow null values
431
421
  * @category Validation Tests
432
422
  */
433
- export declare function required<T, P extends ValidatorMessageParameters<T>>(message: ValidatorMessage<T, P>, nullable?: boolean): ValidatorTest<T>;
423
+ export declare function required<T, P extends ValidatorMessageParameters<T>>(message: ValidatorMessage<T, P>, nullable?: boolean): ValidatorTest<T, never>;
434
424
  interface OneOfValidatorMessageParameters<T> extends ValidatorMessageParameters<T> {
435
425
  values: readonly T[];
436
426
  }
@@ -440,7 +430,7 @@ interface OneOfValidatorMessageParameters<T> extends ValidatorMessageParameters<
440
430
  * @param message Error message
441
431
  * @category Validation Tests
442
432
  */
443
- export declare function oneOf<T extends string | number | boolean | Date>(values: readonly T[], message: ValidatorMessage<T, OneOfValidatorMessageParameters<T>>): ValidatorTest<T>;
433
+ export declare function oneOf<T extends string | number | boolean | Date>(values: readonly T[], message: ValidatorMessage<T, OneOfValidatorMessageParameters<T>>): ValidatorTest<T, never>;
444
434
  //#endregion
445
435
  //#region src/factories.d.ts
446
436
  /**
@@ -451,14 +441,14 @@ export declare function oneOf<T extends string | number | boolean | Date>(values
451
441
  * @param applyConfig Function that applies configuration to value.
452
442
  * @category Helpers
453
443
  */
454
- export declare function createTypeValidatorTest<T, C extends ConfigBase<T>>(defaultConfig: C, applyConfig: (value: unknown, config: C) => T | null | undefined): ValidatorFactory<C, T, string>;
444
+ export declare function createTypeValidatorTest<T, C extends ConfigBase<T>>(defaultConfig: NoInfer<C>, applyConfig: (value: unknown, config: C) => T | null | undefined): ValidatorFactory<C, T, string>;
455
445
  /**
456
446
  * Captures basic validator test pattern
457
447
  * @param test Test function
458
448
  * @param message Error message
459
449
  * @param getExtras Optional extra fields for error message
460
450
  */
461
- export declare function createValidatorTest<T = any, E = any, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(test: (value: unknown, field?: string) => boolean, message: ValidatorMessage<T, P>, getExtras?: (value: T | null | undefined) => Omit<P, 'value' | 'field'>): ValidatorTest<T, E>;
451
+ export declare function createValidatorTest<T = unknown, E = never, P extends ValidatorMessageParameters<T> = ValidatorMessageParameters<T>>(test: (value: unknown, field?: string) => boolean, message: ValidatorMessage<T, P>, getExtras?: (value: T | null | undefined) => Omit<P, 'value' | 'field'>): ValidatorTest<T, E>;
462
452
  //#endregion
463
453
  //#region src/limits.d.ts
464
454
  type SharedValueType = string | number | unknown[];
@@ -475,7 +465,7 @@ interface MaxValidatorMessageParameters extends ValidatorMessageParameters<Share
475
465
  * @param exclusive Use exclusive comparison instead of inclusive
476
466
  * @category Validation Tests
477
467
  */
478
- export declare function max(limit: number, message: ValidatorMessage<SharedValueType, MaxValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType>;
468
+ export declare function max(limit: number, message: ValidatorMessage<SharedValueType, MaxValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType, never>;
479
469
  interface MinValidatorMessageParameters extends ValidatorMessageParameters<SharedValueType> {
480
470
  min: number;
481
471
  limit: number;
@@ -489,7 +479,7 @@ interface MinValidatorMessageParameters extends ValidatorMessageParameters<Share
489
479
  * @param exclusive Use exclusive comparison instead of inclusive
490
480
  * @category Validation Tests
491
481
  */
492
- export declare function min(limit: number, message: ValidatorMessage<SharedValueType, MinValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType>;
482
+ export declare function min(limit: number, message: ValidatorMessage<SharedValueType, MinValidatorMessageParameters>, exclusive?: boolean): ValidatorTest<SharedValueType, never>;
493
483
  interface ExactValidatorMessageParameters extends ValidatorMessageParameters<SharedValueType> {
494
484
  limit: number;
495
485
  amount: number | null | undefined;
@@ -501,7 +491,7 @@ interface ExactValidatorMessageParameters extends ValidatorMessageParameters<Sha
501
491
  * @param message Error message
502
492
  * @category Validation Tests
503
493
  */
504
- export declare function exact(limit: number, message: ValidatorMessage<SharedValueType, ExactValidatorMessageParameters>): ValidatorTest<SharedValueType>;
494
+ export declare function exact(limit: number, message: ValidatorMessage<SharedValueType, ExactValidatorMessageParameters>): ValidatorTest<SharedValueType, never>;
505
495
  //#endregion
506
496
  //#region src/strings.d.ts
507
497
  /**
@@ -534,28 +524,28 @@ interface MatchesValidatorMessageParameters extends ValidatorMessageParameters<s
534
524
  * @param message Error message
535
525
  * @category Validation Tests
536
526
  */
537
- export declare function matches(pattern: RegExp, message: ValidatorMessage<string, MatchesValidatorMessageParameters>): ValidatorTest<string>;
527
+ export declare function matches(pattern: RegExp, message: ValidatorMessage<string, MatchesValidatorMessageParameters>): ValidatorTest<string, never>;
538
528
  /**
539
529
  * Ensures a string value matches an email pattern
540
530
  * @param message Error message
541
531
  * @category Validation Tests
542
532
  */
543
- export declare function email(message: ValidatorMessage<string>): ValidatorTest<string>;
533
+ export declare function email(message: ValidatorMessage<string>): ValidatorTest<string, never>;
544
534
  /**
545
535
  * Ensures a string value is an RFC 9562 UUID, any version from 1 to 8, or the
546
536
  * nil or max UUID. Case-insensitive, without braces or a `urn:uuid:` prefix.
547
537
  * @param message Error message
548
538
  * @category Validation Tests
549
539
  */
550
- export declare function uuid(message: ValidatorMessage<string>): ValidatorTest<string>;
540
+ export declare function uuid(message: ValidatorMessage<string>): ValidatorTest<string, never>;
551
541
  /**
552
542
  * Ensures a string value is a valid URL
553
543
  * @param message Error message
554
- * @param protocols Optional list of protocols to allow. Without it, `javascript:`
555
- * and `data:` URLs are valid; use `['http:', 'https:']` for values rendered as links.
544
+ * @param protocols Protocols to allow. Defaults to `['http:', 'https:']`; a list
545
+ * replaces the default.
556
546
  * @category Validation Tests
557
547
  */
558
- export declare function url(message: ValidatorMessage<string>, protocols?: string[]): ValidatorTest<string>;
548
+ export declare function url(message: ValidatorMessage<string>, protocols?: string[]): ValidatorTest<string, never>;
559
549
  /**
560
550
  * Validates a string value.
561
551
  * @category Type Validators
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){return Object.prototype.toString.call(e)===`[object Object]`}function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function n(e){return!!Reflect.get(Object(e),Symbol.iterator)}const r=/{(\w+)}/g;function i(e,t){return typeof e==`string`?e.replaceAll(r,(e,n)=>String(t[n])):e(t)}async function a(e){return o(e)}function o({value:e,field:t}){return{isValid:!0,state:`valid`,value:e,field:t}}async function s(e){return c(e)}function c({errors:e,field:t,message:n,value:r,extras:a}){return{isValid:!1,state:`invalid`,message:i(n,{...a,value:r,field:t}),value:r,field:t,errors:e}}function l(e){return Array.isArray(e)||e==null?e:n(e)?[...e]:[]}function u(e,t){let n=e.parser(t);return e.default!==void 0&&(n==null||n.length===0)&&(n=e.default),n}async function d(e,t,n){for(let r of e){let e=await r(t,n);if(e.state===`invalid`)return e}}async function f(e,t,n){let r=!0,i=[];if(!t||!e)return{isValid:r,errors:i,values:t};let a=[];for(let[o,s]of t.entries()){let t=await e(s,n?`${n}[${o}]`:`[${o}]`);a.push(t.value),t.state===`invalid`?(r=!1,i.push(t.message||t.errors)):i.push(null)}return{isValid:r,errors:i,values:a}}function p(e,...t){let n=typeof e==`function`?[e,...t]:t,r={parser:l,...typeof e==`function`?void 0:e};return async(e,t)=>{let i=u(r,e),[o,...c]=n,l=await d(c,i,t),p=await f(o,i,t);return!l&&p.isValid?a({value:p.values,field:t}):s({message:l?l.message:``,value:e,field:t,errors:p.errors})}}const m=/* @__PURE__ */ new WeakMap;function h(e,t){return(n,...r)=>{let i=e,a=r;return n!==void 0&&(typeof n==`function`?a=[n,...r]:i={...e,...n}),async(e,n)=>{try{let r=t(e,i);for(let e of a){let t=m.get(e),i;if(i=t?t(r,n):await e(r,n),i.state===`invalid`)return i}return o({value:r,field:n})}catch(t){return s({message:t instanceof Error?t.message:String(t),value:e,field:n})}}}}function g(e,t,n){let r=(r,i)=>e(r,i)?o({value:r,field:i}):c({message:t,value:r,field:i,extras:n?n(r):void 0}),i=async(e,t)=>r(e,t);return m.set(i,r),i}function _(e){return e==null||typeof e==`boolean`?e:!!e}function v(e,t){let n=t.parser(e);return t.default!==void 0&&n==null&&(n=t.default),n}const y=h({parser:_},v),b=/* @__PURE__ */ new Date(``),x=/^(\d{4})(?:-([0-2]\d)(?:-([0-3]\d)(?:[ T]([0-2]\d):([0-5]\d)(?::([0-5]\d)(\.\d+)?(Z|[+-][0-2]\d:?[0-5]\d)?)?)?)?)?$/,S=/^([+-])([0-2]\d):?([0-5]\d)$/;function C(e){let t=S.exec(e);if(e===`Z`||!t)return 0;let[,n,r,i]=t;return(n===`-`?-1:1)*(Number(r)*60+Number(i))}const w=[()=>0,e=>Number(e),(e=`1`)=>Number.parseInt(e,10)-1,(e=`1`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseFloat(e)*1e3];function T(e){return e==null||e instanceof Date?e:typeof e==`number`?new Date(e):typeof e==`string`?E(e):b}function E(e){let t=x.exec(e);if(t===null)return b;let[,n=0,r=0,i=0,a=0,o=0,s=0,c=0]=w.map((e,n)=>e(t[n])),l=t[8];return l?new Date(Date.UTC(n,r,i,a,o+C(l),s,c)):new Date(n,r,i,a,o,s,c)}function D(e,t){let n=t.parser(e);return t.default!==void 0&&(n==null||Number.isNaN(n.getTime()))&&(n=t.default),n}function O(e,t,n){let r=T(e);return g(e=>r!=null&&(e==null||e instanceof Date&&(n?e>r:e>=r)),t,()=>({min:r,limit:r,exclusive:n}))}function k(e,t,n){let r=T(e);return g(e=>r!=null&&(e==null||e instanceof Date&&(n?e<r:e<=r)),t,()=>({max:r,limit:r,exclusive:n}))}const A=h({parser:T},D);function j(e){return e==null||typeof e==`number`?e:e instanceof Date?e.getTime():typeof e==`string`?Number.parseFloat(e):Number.parseFloat(String(e))}function M(e,t){let n=t.parser(e);if(t.default!==void 0&&(n==null||Number.isNaN(n))&&(n=t.default),t.round&&typeof n==`number`)switch(t.round){case`nearest`:n=Math.round(n);break;case`ceil`:n=Math.ceil(n);break;case`floor`:n=Math.floor(n);break;default:throw Error(`Unknown round type: ${String(t.round)}`)}return n}function N(e){return async(t,n)=>t==null||typeof t==`number`&&Number.isFinite(t)&&Math.floor(t)===t?a({value:t,field:n}):s({message:e,value:t,field:n})}const P=h({parser:j},M);function F(...e){let[t,n,r]=e.length===2?[[],...e]:e,o=typeof t==`string`?[t]:t;return async(e,t)=>{let c=e;return n(c)?a({value:c,field:t}):o.length===0?s({message:r,value:c,field:t}):s({message:``,value:c,field:t,errors:o.reduceRight((e,t)=>({[t]:e}),i(r,{value:c,field:t}))})}}function I(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}async function L(e,t,n){for(let r of e){let e=await r(t,n);if(e.state===`invalid`)return e}}function R(e,...n){if(typeof e!=`object`||!e)throw TypeError("`properties` must be a configuration object");return async(r,i)=>{let o=r??{},c={},l={},u=!0;for(let n in e)if(t(e,n)){let r=e[n],i=t(o,n)?o[n]:void 0,a=await(typeof r==`function`?r(i,n):s({field:n,message:`No validator set`,value:i}));I(l,n,a.value),a.state===`invalid`&&(u=!1,I(c,n,a.message||a.errors))}if(!u)return s({message:``,value:r,field:i,errors:c});let d=await L(n,l,i);return d?s({message:d.message,value:r,field:i,errors:d.errors}):a({value:l,field:i})}}const z=`Invalid value.`;function B(e,t,n){if(typeof e==`string`)n.push({message:e,path:t});else if(Array.isArray(e))for(let[r,i]of e.entries())i!==null&&B(i,[...t,r],n);else if(typeof e==`object`&&e)for(let r of Object.keys(e))B(Reflect.get(e,r),[...t,r],n);else n.push({message:z,path:t})}function V(e){return Object.assign((t,n)=>e(t,n),{"~standard":{version:1,vendor:`validator-fns`,validate:async t=>{let n=await e(t);if(n.state===`valid`)return{value:n.value};let r=n.message?[{message:n.message}]:[];return n.errors!==void 0&&B(n.errors,[],r),{issues:r.length>0?r:[{message:z}]}}}})}function H(e,t){return g(e=>t&&e===null||e!=null&&(typeof e!=`string`||e!==``)&&!(typeof e==`number`&&Number.isNaN(e))&&!(e instanceof Date&&Number.isNaN(e.valueOf())),e)}function U(e,t){return g(t=>t==null||e.includes(t)||t instanceof Date&&e.some(e=>e.valueOf()===t.valueOf()),t,()=>({values:e}))}function W(e){return typeof e==`string`||Array.isArray(e)?e.length:e}function G(e,t,n){return g(t=>{let r=W(t);return r==null||t===``||(n?r<e:r<=e)},t,t=>({max:e,limit:e,amount:W(t),exclusive:n}))}function K(e,t,n){return g(t=>{let r=W(t);return r==null||t===``||(n?r>e:r>=e)},t,t=>({min:e,limit:e,amount:W(t),exclusive:n}))}function q(e,t){return g(t=>{let n=W(t);return n==null||t===``||n===e},t,t=>({amount:W(t),limit:e,exact:e}))}const J=/^[\w!#$%&'*+./=?^`{|}~-]+@[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?)*$/,Y=/^(?:[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}|0{8}-0{4}-0{4}-0{4}-0{12}|f{8}-f{4}-f{4}-f{4}-f{12})$/i;function X(t){if(t==null||typeof t==`string`)return t;if(t instanceof Date)return t.toISOString();if(e(t))throw TypeError(`Failed to parse value to string.`);return String(t)}function Z(e,t){let n=t.parser(e);return t.default!==void 0&&(n==null||n===``)&&(n=t.default),t.trim&&typeof n==`string`&&(n=n.trim()),n}function Q(e,t){let n=new RegExp(e);return g(e=>(n.lastIndex=0,e==null||e===``||typeof e==`string`&&n.test(e)),t,()=>({pattern:e}))}function $(e){return Q(J,e)}function ee(e){return Q(Y,e)}function te(e,t){return g(e=>{try{let n;if(e==null||e===``||typeof e==`string`&&(n=new URL(e)))return!(n&&t&&!t.includes(n.protocol))}catch{}return!1},e,()=>({protocols:t}))}const ne=h({parser:X},Z);export{u as applyArrayConfig,v as applyBooleanConfig,D as applyDateConfig,M as applyNumberConfig,Z as applyStringConfig,p as array,y as boolean,F as check,h as createTypeValidatorTest,g as createValidatorTest,A as date,$ as email,q as exact,i as formatMessage,t as hasOwnProperty,N as integer,s as invalid,b as invalidDate,e as isObject,Q as matches,G as max,k as maxDate,K as min,O as minDate,P as number,R as object,U as oneOf,l as parseArray,_ as parseBoolean,T as parseDate,j as parseNumber,X as parseString,H as required,V as standard,ne as string,te as url,ee as uuid,a as valid};
1
+ function e(e){return e.message||e.errors===void 0?e.message:e.errors}function t(e){return Object.prototype.toString.call(e)===`[object Object]`}function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function r(e){return!!Reflect.get(Object(e),Symbol.iterator)}const i=/{(\w+)}/g;function a(e,t){return typeof e==`string`?e.replaceAll(i,(e,n)=>String(Reflect.get(t,n))):e(t)}async function o(e){return s(e)}function s({value:e,field:t}){return{state:`valid`,value:e,field:t}}async function c(e){return l(e)}function l({errors:e,field:t,message:n,value:r,extras:i}){return{state:`invalid`,message:a(n,{...i,value:r,field:t}),value:r,field:t,errors:e}}function u(e){return Array.isArray(e)||e==null?e:r(e)?[...e]:[]}function d(e,t){let n=e.parser(t);return e.default!==void 0&&(n==null||n.length===0)&&(n=e.default),n}async function f(e,t,n){for(let r of e){let e=await r(t,n);if(e.state===`invalid`)return e}}async function p(t,n,r){let i=!0,a=[];if(!n||!t)return{isValid:i,errors:a,values:n};let o=[];for(let[s,c]of n.entries()){let n=await t(c,`${r||``}[${s}]`);o.push(n.value),n.state===`invalid`?(i=!1,a.push(e(n))):a.push(null)}return{isValid:i,errors:a,values:o}}function m(e,...t){let n=typeof e==`function`?[e,...t]:t,r={parser:u,...typeof e==`function`?void 0:e};return async(e,t)=>{let i=d(r,e),[a,...s]=n,l=await f(s,i,t),u=await p(a,i,t);return!l&&u.isValid?o({value:u.values,field:t}):c({message:l?l.message:``,value:e,field:t,errors:u.errors})}}const h=/* @__PURE__ */ new WeakMap;function g(e,t){return(n,...r)=>{let i=e,a=r;return n!==void 0&&(typeof n==`function`?a=[n,...r]:i={...e,...n}),async(e,n)=>{try{let r=t(e,i);for(let e of a){let t=h.get(e),i;if(i=t?t(r,n):await e(r,n),i.state===`invalid`)return i}return s({value:r,field:n})}catch(t){return c({message:t instanceof Error?t.message:String(t),value:e,field:n})}}}}function _(e,t,n){let r=(r,i)=>e(r,i)?s({value:r,field:i}):l({message:t,value:r,field:i,extras:n?n(r):void 0}),i=async(e,t)=>r(e,t);return h.set(i,r),i}function v(e){return e==null||typeof e==`boolean`?e:!!e}function y(e,t){let n=t.parser(e);return t.default!==void 0&&n==null&&(n=t.default),n}const b=g({parser:v},y),x=/* @__PURE__ */ new Date(``),S=/^(\d{4})(?:-([0-2]\d)(?:-([0-3]\d)(?:[ T]([0-2]\d):([0-5]\d)(?::([0-5]\d)(\.\d+)?(Z|[+-][0-2]\d:?[0-5]\d)?)?)?)?)?$/,C=/^([+-])([0-2]\d):?([0-5]\d)$/;function w(e){let t=C.exec(e);if(e===`Z`||!t)return 0;let[,n,r,i]=t;return(n===`-`?-1:1)*(Number(r)*60+Number(i))}const T=[()=>0,e=>Number(e),(e=`1`)=>Number.parseInt(e,10)-1,(e=`1`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseInt(e,10),(e=`0`)=>Number.parseFloat(e)*1e3];function E(e){return e==null||e instanceof Date?e:typeof e==`number`?new Date(e):typeof e==`string`?D(e):x}function D(e){let t=S.exec(e);if(t===null)return x;let[,n=0,r=0,i=0,a=0,o=0,s=0,c=0]=T.map((e,n)=>e(t[n])),l=t[8];return l?new Date(Date.UTC(n,r,i,a,o+w(l),s,c)):new Date(n,r,i,a,o,s,c)}function O(e,t){let n=t.parser(e);return t.default!==void 0&&(n==null||Number.isNaN(n.getTime()))&&(n=t.default),n}function k(e,t,n){let r=E(e);return _(e=>r!=null&&(e==null||e instanceof Date&&(n?e>r:e>=r)),t,()=>({min:r,limit:r,exclusive:n}))}function ee(e,t,n){let r=E(e);return _(e=>r!=null&&(e==null||e instanceof Date&&(n?e<r:e<=r)),t,()=>({max:r,limit:r,exclusive:n}))}const te=g({parser:E},O),ne=[e=>String.prototype.valueOf.call(e),e=>Number.prototype.valueOf.call(e),e=>Boolean.prototype.valueOf.call(e)];function A(e){if(typeof e!=`object`||!e)return e;for(let t of ne)try{return t(e)}catch{}return e}function j(e){let t=A(e);switch(typeof t){case`string`:case`number`:case`bigint`:case`boolean`:return String(t);default:return}}function M(e){if(e==null||typeof e==`number`)return e;if(e instanceof Date)return e.getTime();let t=j(e),n=t===void 0?NaN:Number.parseFloat(t);if(Number.isNaN(n)&&(t===void 0||t.trim()!==``))throw TypeError(`Failed to parse value to number.`);return n}function N(e,t){let n=t.parser(e);if(t.default!==void 0&&(n==null||Number.isNaN(n))&&(n=t.default),t.round&&typeof n==`number`)switch(t.round){case`nearest`:n=Math.round(n);break;case`ceil`:n=Math.ceil(n);break;case`floor`:n=Math.floor(n);break;default:throw Error(`Unknown round type: ${String(t.round)}`)}return n}function P(e){return async(t,n)=>t==null||typeof t==`number`&&Number.isFinite(t)&&Math.floor(t)===t?o({value:t,field:n}):c({message:e,value:t,field:n})}const F=g({parser:M},N);function I(...e){let[t,n,r]=e.length===2?[[],...e]:e,i=typeof t==`string`?[t]:t;return async(e,t)=>{let s=e;return n(s)?o({value:s,field:t}):i.length===0?c({message:r,value:s,field:t}):c({message:``,value:s,field:t,errors:i.reduceRight((e,t)=>({[t]:e}),a(r,{value:s,field:t}))})}}function L(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}async function R(e,t,n){for(let r of e){let e=await r(t,n);if(e.state===`invalid`)return e}}function z(t,...r){if(typeof t!=`object`||!t)throw TypeError("`properties` must be a configuration object");return async(i,a)=>{let s=Object(i),l={},u={},d=!0;for(let r in t)if(n(t,r)){let i=t[r],a=n(s,r)?Reflect.get(s,r):void 0,o=await(typeof i==`function`?i(a,r):c({field:r,message:`No validator set`,value:a}));L(u,r,o.value),o.state===`invalid`&&(d=!1,L(l,r,e(o)))}if(!d)return c({message:``,value:i,field:a,errors:l});let f=await R(r,u,a);return f?c({message:f.message,value:i,field:a,errors:f.errors}):o({value:u,field:a})}}const B=`Invalid value.`;function V(e,t,n){if(typeof e==`string`)n.push({message:e||B,path:t});else if(Array.isArray(e))for(let[r,i]of e.entries())i!==null&&V(i,[...t,r],n);else if(typeof e==`object`&&e)for(let r of Object.keys(e))V(Reflect.get(e,r),[...t,r],n);else n.push({message:B,path:t})}function H(e){return Object.assign((t,n)=>e(t,n),{"~standard":{version:1,vendor:`validator-fns`,validate:async t=>{let n=await e(t);if(n.state===`valid`)return{value:n.value};let r=n.message?[{message:n.message}]:[];return n.errors!==void 0&&V(n.errors,[],r),{issues:r.length>0?r:[{message:B}]}}}})}function U(e,t){return _(e=>t&&e===null||e!=null&&(typeof e!=`string`||e!==``)&&!(typeof e==`number`&&Number.isNaN(e))&&!(e instanceof Date&&Number.isNaN(e.valueOf())),e)}function W(e,t){let n=e;return _(t=>t==null||n.includes(t)||t instanceof Date&&e.some(e=>e.valueOf()===t.valueOf()),t,()=>({values:e}))}function G(e){return typeof e==`string`||Array.isArray(e)?e.length:e}function K(e,t,n){return _(t=>{let r=G(t);return r==null||t===``||(n?r<e:r<=e)},t,t=>({max:e,limit:e,amount:G(t),exclusive:n}))}function q(e,t,n){return _(t=>{let r=G(t);return r==null||t===``||(n?r>e:r>=e)},t,t=>({min:e,limit:e,amount:G(t),exclusive:n}))}function J(e,t){return _(t=>{let n=G(t);return n==null||t===``||n===e},t,t=>({amount:G(t),limit:e,exact:e}))}const Y=/^[\w!#$%&'*+./=?^`{|}~-]+@[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?)*$/,X=/^(?:[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}|0{8}-0{4}-0{4}-0{4}-0{12}|f{8}-f{4}-f{4}-f{4}-f{12})$/i;function Z(e){if(e==null||typeof e==`string`)return e;if(e instanceof Date)return e.toISOString();let t=j(e);if(t===void 0)throw TypeError(`Failed to parse value to string.`);return t}function Q(e,t){let n=t.parser(e);return t.default!==void 0&&(n==null||n===``)&&(n=t.default),t.trim&&typeof n==`string`&&(n=n.trim()),n}function $(e,t){let n=new RegExp(e);return _(e=>(n.lastIndex=0,e==null||e===``||typeof e==`string`&&n.test(e)),t,()=>({pattern:e}))}function re(e){return $(Y,e)}function ie(e){return $(X,e)}function ae(e,t=[`http:`,`https:`]){return _(e=>{try{let n;if(e==null||e===``||typeof e==`string`&&(n=new URL(e)))return!n||t.includes(n.protocol)}catch{}return!1},e,()=>({protocols:t}))}const oe=g({parser:Z},Q);export{d as applyArrayConfig,y as applyBooleanConfig,O as applyDateConfig,N as applyNumberConfig,Q as applyStringConfig,m as array,b as boolean,I as check,g as createTypeValidatorTest,_ as createValidatorTest,te as date,re as email,J as exact,a as formatMessage,n as hasOwnProperty,P as integer,c as invalid,x as invalidDate,t as isObject,$ as matches,K as max,ee as maxDate,q as min,k as minDate,F as number,z as object,W as oneOf,u as parseArray,v as parseBoolean,E as parseDate,M as parseNumber,Z as parseString,U as required,H as standard,oe as string,ae as url,ie as uuid,o as valid};
2
2
  //# sourceMappingURL=index.js.map