UNPKG

zod

Version:

Typescript-first schema declaration and validation library with static type inference

23 lines (18 loc) 597 B
import * as z from './base'; import { ZodUnion } from './union'; import { ZodNull } from './null'; export interface ZodUndefinedDef extends z.ZodTypeDef { t: z.ZodTypes.undefined; } export class ZodUndefined extends z.ZodType<undefined> { toJSON = () => this._def; optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]); nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]); static create = (): ZodUndefined => { return new ZodUndefined({ t: z.ZodTypes.undefined, }); }; }