Skip to main content
Module

x/zod/mod.ts>z.ZodObject

TypeScript-first schema validation with static type inference
Extremely Popular
Go to Latest
class z.ZodObject
import { z } from "https://deno.land/x/zod@3.0.0-alpha.39/mod.ts";
const { ZodObject } = z;

Type Parameters

T extends ZodRawShape
optional
UnknownKeys extends UnknownKeysParam = "strip"
optional
Catchall extends ZodTypeAny = ZodTypeAny
optional
Output = objectOutputType<T, Catchall>
optional
Input = objectInputType<T, Catchall>

Properties

readonly
_catchall: Catchall
readonly
_shape: T
readonly
_unknownKeys: UnknownKeys
augment
catchall: <Index extends ZodTypeAny>(index: Index) => ZodObject<T, UnknownKeys, Index>
deepPartial: () => partialUtil.RootDeepPartial<this>
extend
merge: <Incoming extends AnyZodObject>(merging: Incoming) => ZodObject<extend<T, Incoming["_shape"]>, UnknownKeys, Catchall>

Prior to zod@1.0.12 there was a bug in the inferred type of merged objects. Please upgrade if you are experiencing issues.

nonstrict
omit: <Mask extends [k in keyof T]?: true>(mask: Mask) => ZodObject<objectUtil.noNever<[k in keyof T]: k extends keyof Mask ? never : T[k]>, UnknownKeys, Catchall>
partial: () => ZodObject<[k in keyof T]: ReturnType<T[k]["optional"]>, UnknownKeys, Catchall>
passthrough: () => ZodObject<T, "passthrough", Catchall>
pick: <Mask extends [k in keyof T]?: true>(mask: Mask) => ZodObject<objectUtil.noNever<[k in keyof Mask]: k extends keyof T ? T[k] : never>, UnknownKeys, Catchall>
required: () => ZodObject<[k in keyof T]: deoptional<T[k]>, UnknownKeys, Catchall>
setKey: <Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema) => ZodObject<T & [k in Key]: Schema, UnknownKeys, Catchall>
readonly
shape
strict: () => ZodObject<T, "strict", Catchall>
strip: () => ZodObject<T, "strip", Catchall>

Static Properties

create: <T extends ZodRawShape>(shape: T) => ZodObject<T>
lazycreate: <T extends ZodRawShape>(shape: () => T) => ZodObject<T>
strictCreate: <T extends ZodRawShape>(shape: T) => ZodObject<T, "strict">