Skip to main content
Module

x/zod/types.ts>ZodSchema

TypeScript-first schema validation with static type inference
Extremely Popular
Go to Latest
class ZodSchema
Abstract
import { ZodSchema } from "https://deno.land/x/zod@v3.2/types.ts";

Constructors

new
ZodSchema(def: Def)

Type Parameters

Output
optional
Def extends ZodTypeDef = ZodTypeDef
optional
Input = Output

Properties

readonly
_def: Def
readonly
_input: Input
readonly
_output: Output
_parseInternalOptionalParams: (params: ParseParamsWithOptionals) => ZodParserReturnType<Output>
_parseWithInvalidFallback: (data: unknown, params: ParseParamsNoData) => Promise<Output | INVALID> | Output | INVALID
readonly
_type: Output
array: () => ZodArray<this>
check: never

The .check method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3.

is: never

The .is method has been removed in Zod 3. For details see https://github.com/colinhacks/zod/tree/v3.

isNullable: () => boolean
isOptional: () => boolean
nullable: <This extends this = this>() => ZodNullable<This>
nullish: <This extends this = this>() => ZodNullable<ZodOptional<This>>
optional: <This extends this = this>() => ZodOptional<This>
parse: (data: unknown, params?: Partial<ParseParamsNoData>) => Output
parseAsync: (x: unknown, params?: Partial<ParseParamsNoData>) => Promise<Output>
refine: <Func extends (arg: Output) => any, This extends this = this>(check: Func, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)) => ZodEffectsType<This>
refinement: <This extends this = this>(check: (arg: Output) => any, refinementData: MakeErrorData | ((arg: Output, ctx: RefinementCtx) => MakeErrorData)) => ZodEffectsType<This>
safeParse: (data: unknown, params?: Partial<ParseParamsNoData>) => { success: true; data: Output; } | { success: false; error: ZodError<Input>; }
safeParseAsync: (x: unknown, params?: Partial<ParseParamsNoData>) => Promise<{ success: true; data: Output; } | { success: false; error: ZodError; }>
spa

Alias of safeParseAsync

superRefine

Methods

abstract
_parse(_ctx: ParseContext): any
_refinement<This extends this>(refinement: InternalCheck<Output>["refinement"]): ZodEffectsType<This>
and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>
default<This extends this = this>(def: util.noUndefined<Input>): ZodDefault<This>
default<This extends this = this>(def: () => util.noUndefined<Input>): ZodDefault<This>
default(def: any)
or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>
transform<NewOut>(transform: (arg: Output) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>