Class ZodObject<T, UnknownKeys, Catchall, Output, Input>

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_input: Input
_output: Output
_type: Output
augment: <Augmentation extends Zod.z.ZodRawShape>(
    augmentation: Augmentation,
) => Zod.z.ZodObject<
    {
        [k in string
        | number
        | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
    },
    UnknownKeys,
    Catchall,
    Zod.z.objectOutputType<
        {
            [k in string
            | number
            | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
        },
        Catchall,
        UnknownKeys,
    >,
    Zod.z.objectInputType<
        {
            [k in string
            | number
            | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
        },
        Catchall,
        UnknownKeys,
    >,
>

Use .extend instead

nonstrict: () => Zod.z.ZodObject<
    T,
    "passthrough",
    Catchall,
    Zod.z.objectOutputType<T, Catchall, "passthrough">,
    Zod.z.objectInputType<T, Catchall, "passthrough">,
>

In most cases, this is no longer needed - unknown properties are now silently stripped. If you want to pass through unknown properties, use .passthrough() instead.

spa: (
    data: unknown,
    params?: Partial<Zod.z.ParseParams>,
) => Promise<Zod.z.SafeParseReturnType<Input, Output>>

Alias of safeParseAsync

create: <T_1 extends Zod.z.ZodRawShape>(
    shape: T_1,
    params?: Zod.z.RawCreateParams,
) => Zod.z.ZodObject<
    T_1,
    "strip",
    Zod.z.ZodTypeAny,
    {
        [k_1 in string
        | number
        | symbol]: addQuestionMarks<
            Zod.z.baseObjectOutputType<T_1>,
            {
                [k in string | number | symbol]: undefined extends Zod.z.baseObjectOutputType<
                    T_1,
                >[k]
                    ? never
                    : k
            }[keyof T_1],
        >[k_1]
    },
    { [k_2 in string
    | number
    | symbol]: Zod.z.baseObjectInputType<T_1>[k_2] },
>
lazycreate: <T_1 extends Zod.z.ZodRawShape>(
    shape: () => T_1,
    params?: Zod.z.RawCreateParams,
) => Zod.z.ZodObject<
    T_1,
    "strip",
    Zod.z.ZodTypeAny,
    {
        [k_1 in string
        | number
        | symbol]: addQuestionMarks<
            Zod.z.baseObjectOutputType<T_1>,
            {
                [k in string | number | symbol]: undefined extends Zod.z.baseObjectOutputType<
                    T_1,
                >[k]
                    ? never
                    : k
            }[keyof T_1],
        >[k_1]
    },
    { [k_2 in string
    | number
    | symbol]: Zod.z.baseObjectInputType<T_1>[k_2] },
>
strictCreate: <T_1 extends Zod.z.ZodRawShape>(
    shape: T_1,
    params?: Zod.z.RawCreateParams,
) => Zod.z.ZodObject<
    T_1,
    "strict",
    Zod.z.ZodTypeAny,
    {
        [k_1 in string
        | number
        | symbol]: addQuestionMarks<
            Zod.z.baseObjectOutputType<T_1>,
            {
                [k in string | number | symbol]: undefined extends Zod.z.baseObjectOutputType<
                    T_1,
                >[k]
                    ? never
                    : k
            }[keyof T_1],
        >[k_1]
    },
    { [k_2 in string
    | number
    | symbol]: Zod.z.baseObjectInputType<T_1>[k_2] },
>

Accessors

  • get description(): undefined | string
  • Returns undefined | string

  • get shape(): T
  • Returns T

Methods

  • Returns { keys: string[]; shape: T }

  • Parameters

    • description: string

    Returns this

  • Returns boolean

  • Returns boolean

  • Returns Zod.z.ZodEnum<CastToStringTuple<UnionToTuple<keyof T, []>>>

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

    Type Parameters

    Parameters

    Returns Zod.z.ZodObject<
        {
            [k in string
            | number
            | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
        },
        Incoming["_def"]["unknownKeys"],
        Incoming["_def"]["catchall"],
        Zod.z.objectOutputType<
            {
                [k in string
                | number
                | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
            },
            Incoming["_def"]["catchall"],
            Incoming["_def"]["unknownKeys"],
        >,
        Zod.z.objectInputType<
            {
                [k in string
                | number
                | symbol]: (Omit<T, keyof Augmentation> & Augmentation)[k]
            },
            Incoming["_def"]["catchall"],
            Incoming["_def"]["unknownKeys"],
        >,
    >

  • Returns Zod.z.ZodObject<
        { [k in string
        | number
        | symbol]: Zod.z.ZodOptional<T[k]> },
        UnknownKeys,
        Catchall,
        Zod.z.objectOutputType<
            { [k in string
            | number
            | symbol]: Zod.z.ZodOptional<T[k]> },
            Catchall,
            UnknownKeys,
        >,
        Zod.z.objectInputType<
            { [k in string
            | number
            | symbol]: Zod.z.ZodOptional<T[k]> },
            Catchall,
            UnknownKeys,
        >,
    >

  • Type Parameters

    • Mask extends { [k in string | number | symbol]?: true }

    Parameters

    Returns Zod.z.ZodObject<
        {
            [k in string
            | number
            | symbol]: k extends keyof T
                ? {
                    [k in string | number | symbol]: k extends keyof Mask
                        ? Zod.z.ZodOptional<T[k<k>]>
                        : T[k]
                }[k<k>]
                : never
        },
        UnknownKeys,
        Catchall,
        Zod.z.objectOutputType<
            {
                [k in string
                | number
                | symbol]: k extends keyof T
                    ? {
                        [k in string | number | symbol]: k extends keyof Mask
                            ? Zod.z.ZodOptional<T[k<k>]>
                            : T[k]
                    }[k<k>]
                    : never
            },
            Catchall,
            UnknownKeys,
        >,
        Zod.z.objectInputType<
            {
                [k in string
                | number
                | symbol]: k extends keyof T
                    ? {
                        [k in string | number | symbol]: k extends keyof Mask
                            ? Zod.z.ZodOptional<T[k<k>]>
                            : T[k]
                    }[k<k>]
                    : never
            },
            Catchall,
            UnknownKeys,
        >,
    >

  • Returns Zod.z.ZodObject<
        { [k in string
        | number
        | symbol]: Zod.z.deoptional<T[k]> },
        UnknownKeys,
        Catchall,
        Zod.z.objectOutputType<
            { [k in string
            | number
            | symbol]: Zod.z.deoptional<T[k]> },
            Catchall,
            UnknownKeys,
        >,
        Zod.z.objectInputType<
            { [k in string
            | number
            | symbol]: Zod.z.deoptional<T[k]> },
            Catchall,
            UnknownKeys,
        >,
    >

  • Type Parameters

    • Mask extends { [k in string | number | symbol]?: true }

    Parameters

    Returns Zod.z.ZodObject<
        {
            [k in string
            | number
            | symbol]: k extends keyof T
                ? {
                    [k in string | number | symbol]: k extends keyof Mask
                        ? Zod.z.deoptional<T[k<k>]>
                        : T[k]
                }[k<k>]
                : never
        },
        UnknownKeys,
        Catchall,
        Zod.z.objectOutputType<
            {
                [k in string
                | number
                | symbol]: k extends keyof T
                    ? {
                        [k in string | number | symbol]: k extends keyof Mask
                            ? Zod.z.deoptional<T[k<k>]>
                            : T[k]
                    }[k<k>]
                    : never
            },
            Catchall,
            UnknownKeys,
        >,
        Zod.z.objectInputType<
            {
                [k in string
                | number
                | symbol]: k extends keyof T
                    ? {
                        [k in string | number | symbol]: k extends keyof Mask
                            ? Zod.z.deoptional<T[k<k>]>
                            : T[k]
                    }[k<k>]
                    : never
            },
            Catchall,
            UnknownKeys,
        >,
    >