Class ZodType<Output, Def, Input>Abstract
Type Parameters
-
Output = any
-
-
Input = Output
Constructors
constructor
- new ZodType<Output, Def, Input>(def: Def): ZodType<Output, Def, Input>
-
Type Parameters
-
Output = any
-
-
Input = Output
Returns ZodType<Output, Def, Input>
Properties
Readonly
_def
_def: Def
Readonly
_input
_input: Input
Readonly
_output
_output: Output
Readonly
_type
_type: Output
spa
Accessors
description
- get description(): undefined | string
-
Returns undefined | string
Methods
_getType
- _getType(input: ParseInput): string
-
Returns string
and
- and<T>(incoming: T): ZodIntersection<ZodType<Output, Def, Input>, T>
-
Type Parameters
-
T extends ZodType<any, any, any, T>
array
- array(): ZodArray<ZodType<Output, Def, Input>, "many">
-
Returns ZodArray<ZodType<Output, Def, Input>, "many">
brand
- brand<B>(brand?: B): ZodBranded<ZodType<Output, Def, Input>, B>
-
Type Parameters
-
B extends string | number | symbol
catch
- catch(def: Input): ZodCatch<ZodType<Output, Def, Input>>
-
- catch(def: (() => Input)): ZodCatch<ZodType<Output, Def, Input>>
-
describe
- describe(description: string): ZodType<Output, Def, Input>
-
Returns ZodType<Output, Def, Input>
isNullable
- isNullable(): boolean
-
Returns boolean
isOptional
- isOptional(): boolean
-
Returns boolean
nullable
- nullable(): ZodNullable<ZodType<Output, Def, Input>>
-
optional
- optional(): ZodOptional<ZodType<Output, Def, Input>>
-
or
- or<T>(option: T): ZodUnion<[ZodType<Output, Def, Input>, T]>
-
Type Parameters
-
T extends ZodType<any, any, any, T>
Returns ZodUnion<[ZodType<Output, Def, Input>, T]>
parse
- parse(data: unknown, params?: Partial<ParseParams>): Output
-
Returns Output
parseAsync
- parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>
-
Returns Promise<Output>
pipe
- pipe<T>(target: T): ZodPipeline<ZodType<Output, Def, Input>, T>
-
Type Parameters
-
T extends ZodType<any, any, any, T>
promise
- promise(): ZodPromise<ZodType<Output, Def, Input>>
-
refine
- refine<RefinedOutput>(check: ((arg: Output) => arg is RefinedOutput), message?: string | ((arg: Output) => Partial<Omit<ZodCustomIssue, "code">>) | Partial<Omit<ZodCustomIssue, "code">>): ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
-
Parameters
-
check: ((arg: Output) => arg is RefinedOutput)
-
- (arg: Output): arg is RefinedOutput
-
Returns arg is RefinedOutput
-
Returns ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
- refine(check: ((arg: Output) => unknown), message?: string | Partial<Omit<ZodCustomIssue, "code">> | ((arg: Output) => Partial<Omit<ZodCustomIssue, "code">>)): ZodEffects<ZodType<Output, Def, Input>, Output, Input>
-
Parameters
-
check: ((arg: Output) => unknown)
-
- (arg: Output): unknown
-
Returns unknown
-
Returns ZodEffects<ZodType<Output, Def, Input>, Output, Input>
refinement
- refinement<RefinedOutput>(check: ((arg: Output) => arg is RefinedOutput), refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
-
Parameters
-
check: ((arg: Output) => arg is RefinedOutput)
-
- (arg: Output): arg is RefinedOutput
-
Returns arg is RefinedOutput
-
Returns ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
- refinement(check: ((arg: Output) => boolean), refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<ZodType<Output, Def, Input>, Output, Input>
-
Parameters
-
check: ((arg: Output) => boolean)
-
- (arg: Output): boolean
-
Returns boolean
-
Returns ZodEffects<ZodType<Output, Def, Input>, Output, Input>
superRefine
- superRefine<RefinedOutput>(refinement: ((arg: Output, ctx: RefinementCtx) => arg is RefinedOutput)): ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
-
Parameters
-
refinement: ((arg: Output, ctx: RefinementCtx) => arg is RefinedOutput)
-
- (arg: Output, ctx: RefinementCtx): arg is RefinedOutput
-
Returns arg is RefinedOutput
Returns ZodEffects<ZodType<Output, Def, Input>, RefinedOutput, Input>
- superRefine(refinement: ((arg: Output, ctx: RefinementCtx) => void)): ZodEffects<ZodType<Output, Def, Input>, Output, Input>
-
Returns ZodEffects<ZodType<Output, Def, Input>, Output, Input>
transform
- transform<NewOut>(transform: ((arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>)): ZodEffects<ZodType<Output, Def, Input>, NewOut, Input>
-
Parameters
-
transform: ((arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>)
-
- (arg: Output, ctx: RefinementCtx): NewOut | Promise<NewOut>
-
Returns NewOut | Promise<NewOut>
Returns ZodEffects<ZodType<Output, Def, Input>, NewOut, Input>
Alias of safeParseAsync