Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

ZodObject

import { ZodObject } from "https://esm.sh/zod@3.25.76/index.d.cts";
class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
private _cached;
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
nonstrict: () => ZodObject<T, "passthrough", Catchall>;
get shape(): T;
 
_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>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
omit<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
partial(): ZodObject<[k in keyof T]: ZodOptional<T[k]>, UnknownKeys, Catchall>;
partial<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): 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 util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
required(): ZodObject<[k in keyof T]: deoptional<T[k]>, UnknownKeys, Catchall>;
required<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): 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 create: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>;
static lazycreate: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">;
static strictCreate: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">;
}

§Type Parameters

§
Catchall extends ZodTypeAny = ZodTypeAny
[src]
§
Output = objectOutputType<T, Catchall, UnknownKeys>
[src]
§
Input = objectInputType<T, Catchall, UnknownKeys>
[src]

§Extends

§
ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input>
[src]

§Properties

§
_cached
[src]
§
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>
[src]
§
nonstrict: () => ZodObject<T, "passthrough", Catchall>
[src]
§
shape: T readonly
[src]

§Methods

§
_getCached(): {
shape: T;
keys: string[];
}
[src]
§
_parse(input: ParseInput): ParseReturnType<this["_output"]>
[src]
§
catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>
[src]
§
deepPartial(): partialUtil.DeepPartial<this> deprecated
[src]
@deprecated
§
extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>
[src]
§
merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>
[src]

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 util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>
[src]
§
partial(): ZodObject<[k in keyof T]: ZodOptional<T[k]>, UnknownKeys, Catchall>
[src]
partial<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<[k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k]>, UnknownKeys, Catchall>
[src]
§
passthrough(): ZodObject<T, "passthrough", Catchall>
[src]
§
pick<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>
[src]
§
required(): ZodObject<[k in keyof T]: deoptional<T[k]>, UnknownKeys, Catchall>
[src]
required<Mask extends util.Exactly<[k in keyof T]?: true, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k]>, UnknownKeys, Catchall>
[src]
§
setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & [k in Key]: Schema, UnknownKeys, Catchall>
[src]
§
strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>
[src]
§
strip(): ZodObject<T, "strip", Catchall>
[src]

§Static Properties

§
create: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strip", ZodTypeAny, objectOutputType<Shape, ZodTypeAny, "strip">, objectInputType<Shape, ZodTypeAny, "strip">>
[src]
§
lazycreate: <Shape extends ZodRawShape>(shape: () => Shape, params?: RawCreateParams) => ZodObject<Shape, "strip">
[src]
§
strictCreate: <Shape extends ZodRawShape>(shape: Shape, params?: RawCreateParams) => ZodObject<Shape, "strict">
[src]