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

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_input: Input
_output: Output
_type: Output

Use .extend instead

nonstrict: () => ZodObject<
    T,
    "passthrough",
    Catchall,
    objectOutputType<T, Catchall, "passthrough">,
    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<ParseParams>,
) => Promise<SafeParseReturnType<Input, Output>>

Alias of safeParseAsync

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

Accessors

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

  • get shape(): T
  • Returns T

Methods

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

  • Parameters

    Returns string

  • Parameters

    • description: string

    Returns this

  • Returns boolean

  • Returns boolean

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

  • Parameters

    Returns Output

  • Parameters

    Returns Promise<Output>

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

  • Type Parameters

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

    Parameters

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

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

  • Type Parameters

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

    Parameters

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