Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/zod/index.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@v3.20.5/index.ts";
const { ZodObject } = z;

Type Parameters

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

Properties

private
_cached: { shape: T; keys: string[]; } | null
deprecated
augment
deprecated
nonstrict
readonly
shape

Methods

_getCached(): { shape: T; keys: string[]; }
_parse(input: ParseInput): ParseReturnType<this["_output"]>
catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>
deepPartial(): partialUtil.DeepPartial<this>
extend<Augmentation extends ZodRawShape, NewOutput extends util.flatten<[k in keyof Augmentation | keyof Output]: k extends keyof Augmentation ? Augmentation[k]["_output"] : k extends keyof Output ? Output[k] : never>, NewInput extends util.flatten<[k in keyof Augmentation | keyof Input]: k extends keyof Augmentation ? Augmentation[k]["_input"] : k extends keyof Input ? Input[k] : never>>(augmentation: Augmentation): ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall, NewOutput, NewInput>
keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>
merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"], NewOutput extends [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation ? Augmentation[k]["_output"] : k extends keyof Output ? Output[k] : never, NewInput extends [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation ? Augmentation[k]["_input"] : k extends keyof Input ? Input[k] : never>(merging: Incoming): ZodObject<extendShape<T, ReturnType<Incoming["_def"]["shape"]>>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"], NewOutput, NewInput>

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

omit<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>
partial<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<[k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k]>, UnknownKeys, Catchall>
passthrough(): ZodObject<T, "passthrough", Catchall>
pick<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, T>): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>
required<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k]>, UnknownKeys, Catchall>
setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & [k in Key]: Schema, UnknownKeys, Catchall>
strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>
strip(): ZodObject<T, "strip", Catchall>

Static Properties

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