UNPKG

1.83 kBTypeScriptView Raw
1import { Struct, Refiner } from '../struct.js';
2/**
3 * Ensure that a string, array, map, or set is empty.
4 */
5export declare function empty<T extends string | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>): Struct<T, S>;
6/**
7 * Ensure that a number or date is below a threshold.
8 */
9export declare function max<T extends number | Date, S extends any>(struct: Struct<T, S>, threshold: T, options?: {
10 exclusive?: boolean;
11}): Struct<T, S>;
12/**
13 * Ensure that a number or date is above a threshold.
14 */
15export declare function min<T extends number | Date, S extends any>(struct: Struct<T, S>, threshold: T, options?: {
16 exclusive?: boolean;
17}): Struct<T, S>;
18/**
19 * Ensure that a string, array, map or set is not empty.
20 */
21export declare function nonempty<T extends string | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>): Struct<T, S>;
22/**
23 * Ensure that a string matches a regular expression.
24 */
25export declare function pattern<T extends string, S extends any>(struct: Struct<T, S>, regexp: RegExp): Struct<T, S>;
26/**
27 * Ensure that a string, array, number, date, map, or set has a size (or length, or time) between `min` and `max`.
28 */
29export declare function size<T extends string | number | Date | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>, min: number, max?: number): Struct<T, S>;
30/**
31 * Augment a `Struct` to add an additional refinement to the validation.
32 *
33 * The refiner function is guaranteed to receive a value of the struct's type,
34 * because the struct's existing validation will already have passed. This
35 * allows you to layer additional validation on top of existing structs.
36 */
37export declare function refine<T, S>(struct: Struct<T, S>, name: string, refiner: Refiner<T>): Struct<T, S>;
38//# sourceMappingURL=refinements.d.ts.map
\No newline at end of file