UNPKG

1.28 kBTypeScriptView Raw
1import { Struct, Coercer } from '../struct.js';
2/**
3 * Augment a `Struct` to add an additional coercion step to its input.
4 *
5 * This allows you to transform input data before validating it, to increase the
6 * likelihood that it passes validation—for example for default values, parsing
7 * different formats, etc.
8 *
9 * Note: You must use `create(value, Struct)` on the value to have the coercion
10 * take effect! Using simply `assert()` or `is()` will not use coercion.
11 */
12export declare function coerce<T, S, C>(struct: Struct<T, S>, condition: Struct<C, any>, coercer: Coercer<C>): Struct<T, S>;
13/**
14 * Augment a struct to replace `undefined` values with a default.
15 *
16 * Note: You must use `create(value, Struct)` on the value to have the coercion
17 * take effect! Using simply `assert()` or `is()` will not use coercion.
18 */
19export declare function defaulted<T, S>(struct: Struct<T, S>, fallback: any, options?: {
20 strict?: boolean;
21}): Struct<T, S>;
22/**
23 * Augment a struct to trim string inputs.
24 *
25 * Note: You must use `create(value, Struct)` on the value to have the coercion
26 * take effect! Using simply `assert()` or `is()` will not use coercion.
27 */
28export declare function trimmed<T, S>(struct: Struct<T, S>): Struct<T, S>;
29//# sourceMappingURL=coercions.d.ts.map
\No newline at end of file