UNPKG

zod

Version:

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

32 lines (31 loc) 1.17 kB
import * as z from './base'; import { ZodUndefined } from './undefined'; import { ZodNull } from './null'; import { ZodUnion } from './union'; export interface ZodObjectDef<T extends z.ZodRawShape = z.ZodRawShape> extends z.ZodTypeDef { t: z.ZodTypes.object; shape: T; } declare type OptionalKeys<T extends z.ZodRawShape> = { [k in keyof T]: undefined extends T[k]['_type'] ? k : never; }[keyof T]; declare type RequiredKeys<T extends z.ZodRawShape> = Exclude<keyof T, OptionalKeys<T>>; declare type ObjectType<T extends z.ZodRawShape> = { [k in OptionalKeys<T>]?: T[k]['_type']; } & { [k in RequiredKeys<T>]: T[k]['_type']; }; export declare class ZodObject<T extends z.ZodRawShape> extends z.ZodType<ObjectType<T>, // { [k in keyof T]: T[k]['_type'] }, ZodObjectDef<T>> { toJSON: () => { t: z.ZodTypes.object; shape: { [x: string]: object; }[]; }; merge: <U extends ZodObject<any>>(other: U) => ZodObject<T & U>; optional: () => ZodUnion<[this, ZodUndefined]>; nullable: () => ZodUnion<[this, ZodNull]>; static create: <T_1 extends z.ZodRawShape>(shape: T_1) => ZodObject<T_1>; } export {};