UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

16 lines (15 loc) 735 B
import type { Schema } from "./Schema.js"; import { ThroughSchema, type ThroughSchemaOptions } from "./ThroughSchema.js"; /** Allowed options for `NullableSchema` */ export interface NullableSchemaOptions<T> extends ThroughSchemaOptions<T | null> { /** Default value (defaults to `null`). */ readonly value?: T | null; } /** Validate a value of a specific type or `null`. */ export declare class NullableSchema<T> extends ThroughSchema<T | null> { readonly value: T | null; constructor({ value, ...options }: NullableSchemaOptions<T>); validate(unsafeValue?: unknown): T | null; } /** Create a new nullable schema from a source schema. */ export declare const NULLABLE: <T>(source: Schema<T>) => NullableSchema<T>;