zod
Version:
Typescript-first schema declaration and validation library with static type inference
38 lines (37 loc) • 1.21 kB
TypeScript
import { ZodTuple } from './tuple';
export declare enum ZodTypes {
string = "string",
number = "number",
boolean = "boolean",
undefined = "undefined",
null = "null",
array = "array",
object = "object",
union = "union",
intersection = "intersection",
tuple = "tuple",
function = "function",
lazy = "lazy"
}
export declare type ZodRawShape = {
[k: string]: ZodAny;
};
export interface ZodTypeDef {
t: ZodTypes;
}
export declare type ZodAny = ZodType<any>;
export declare type TypeOf<T extends ZodAny> = T['_type'];
export declare type TypeOfTuple<T extends [ZodAny, ...ZodAny[]] | []> = {
[k in keyof T]: T[k] extends ZodType<infer U> ? U : never;
};
export declare type TypeOfFunction<Args extends ZodTuple<any>, Returns extends ZodAny> = Args['_type'] extends Array<any> ? (...args: Args['_type']) => Returns['_type'] : never;
export declare abstract class ZodType<Type, Def extends ZodTypeDef = ZodTypeDef> {
readonly _type: Type;
readonly _def: Def;
parse: (x: unknown) => Type;
is(u: any): u is Type;
constructor(def: Def);
abstract toJSON: () => object;
abstract optional: () => any;
abstract nullable: () => any;
}