UNPKG

object-shape-tester

Version:
23 lines (22 loc) 806 B
/** * Creates a shape that is optional, possibly null, and possibly undefined. * * @category Shape * @example * * ```ts * import {nullableShape, checkValidShape, defineShape} from 'object-shape-tester'; * * const myShape = defineShape({ * a: '', * b: nullableShape(-1), * }); * * checkValidShape({a: 'hi', b: 0}, myShape); // `true` * checkValidShape({a: 'hi', b: undefined}, myShape); // `true` * checkValidShape({a: 'hi', b: null}, myShape); // `true` * checkValidShape({a: 'hi'}, myShape); // `true` * checkValidShape({b: 0}, myShape); // `false` * ``` */ export declare function nullableShape<T>(shape: T): import("../index.js").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<import("../index.js").ShapeInitSchema<T | null | undefined>[]>>>;