Module

x/zod/mod.ts>z.Schema

TypeScript-first schema validation with static type inference
Extremely Popular
Go to Latest
class z.Schema
Abstract
import { z } from "https://dotland.deno.dev/x/zod@v3.19.0/mod.ts";
const { Schema } = z;

Constructors

new
Schema(def: Def)

Type Parameters

optional
Output = any
optional
Def extends ZodTypeDef = ZodTypeDef
optional
Input = Output

Properties

readonly
_def: Def
readonly
_input: Input
readonly
_output: Output
readonly
_type: Output
readonly
description
spa

Alias of safeParseAsync

superRefine

Methods

_getType(input: ParseInput): string
_refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>
and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>
array(): ZodArray<this>
brand<B extends string | number | symbol>(): ZodBranded<this, B>
default(def: util.noUndefined<Input>): ZodDefault<this>
default(def: () => util.noUndefined<Input>): ZodDefault<this>
describe(description: string): this
isNullable(): boolean
isOptional(): boolean
or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>
parse(data: unknown, params?: Partial<ParseParams>): Output
parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>
refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, RefinedOutput>
refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>
refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, RefinedOutput>
refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>
safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output>
safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>
transform<NewOut>(transform: (arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>