interface-forge - v2.5.0
    Preparing search index...

    Interface ZodObject<Shape, Config>

    interface ZodObject<
        out Shape extends $ZodShape = $ZodLooseShape,
        out Config extends $ZodObjectConfig = $strip,
    > {
        _def: $ZodObjectDef<Shape>;
        _input: $InferObjectInput<Shape, Config["in"]>;
        _output: $InferObjectOutput<Shape, Config["out"]>;
        _zod: $ZodObjectInternals;
        "~standard": $ZodStandardSchema<ZodObject<Shape, Config>>;
        def: $ZodObjectDef<Shape>;
        description?: string;
        shape: Shape;
        spa: (
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ) => Promise<ZodSafeParseResult<$InferObjectOutput<Shape, Config["out"]>>>;
        type: "object";
        and<T extends SomeType>(
            incoming: T,
        ): ZodIntersection<ZodObject<Shape, Config>, T>;
        array(): ZodArray<ZodObject<Shape, Config>>;
        brand<T extends PropertyKey = PropertyKey>(
            value?: T,
        ): PropertyKey extends T
            ? ZodObject<Shape, Config>
            : $ZodBranded<ZodObject<Shape, Config>, T>;
        catch(def: $InferObjectOutput<Shape>): ZodCatch<ZodObject<Shape, Config>>;
        catch(
            def: (ctx: $ZodCatchCtx) => $InferObjectOutput<Shape>,
        ): ZodCatch<ZodObject<Shape, Config>>;
        catchall<T extends SomeType>(schema: T): ZodObject<Shape, $catchall<T>>;
        check(
            ...checks: (
                | CheckFn<$InferObjectOutput<Shape, Config["out"]>>
                | $ZodCheck<$InferObjectOutput<Shape, Config["out"]>>
            )[],
        ): this;
        clone(def?: $ZodObjectDef<Shape>, params?: { parent: boolean }): this;
        default(
            def: $InferObjectOutput<Shape>,
        ): ZodDefault<ZodObject<Shape, Config>>;
        default(
            def: () => NoUndefined<$InferObjectOutput<Shape, Config["out"]>>,
        ): ZodDefault<ZodObject<Shape, Config>>;
        describe(description: string): this;
        extend<U extends $ZodLooseShape & Partial<Record<keyof Shape, SomeType>>>(
            shape: U,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: (
                    (keyof Shape & keyof U) extends never
                        ? Shape & U
                        : {
                            [K in string | number | symbol as K extends keyof U ? never : K]: Shape[K]
                        } & { [K in string
                        | number
                        | symbol]: U[K] }
                )[k]
            },
            Config,
        >;
        isNullable(): boolean;
        isOptional(): boolean;
        keyof(): ZodEnum<{ [k in string]: { [k in string]: k }[k] }>;
        loose(): ZodObject<Shape, $loose>;
        merge<U extends ZodObject<$ZodLooseShape, $strip>>(
            other: U,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: (
                    (keyof Shape & keyof U["shape"]) extends never
                        ? Shape & U["shape"]
                        : {
                            [K in string | number | symbol as K extends keyof U["shape"]
                                ? never
                                : K]: Shape[K]
                        } & { [K in string
                        | number
                        | symbol]: U["shape"][K] }
                )[k]
            },
            U["_zod"]["config"],
        >;
        meta(): | undefined
        | {
            deprecated?: boolean;
            description?: string;
            example?: unknown;
            examples?: | unknown[]
            | { [key: string]: { value: unknown; [key: string]: unknown } };
            id?: string;
            title?: string;
            [key: string]: unknown;
        };
        meta(
            data: {
                deprecated?: boolean;
                description?: string;
                example?: unknown;
                examples?:
                    | unknown[]
                    | { [key: string]: { value: unknown; [key: string]: unknown } };
                id?: string;
                title?: string;
                [key: string]: unknown;
            },
        ): this;
        nonoptional(
            params?:
                | string
                | {
                    error?: string
                    | $ZodErrorMap<$ZodIssueInvalidType<unknown>>;
                    message?: string;
                },
        ): ZodNonOptional<ZodObject<Shape, Config>>;
        nullable(): ZodNullable<ZodObject<Shape, Config>>;
        nullish(): ZodOptional<ZodNullable<ZodObject<Shape, Config>>>;
        omit<M extends Exactly<Mask<keyof Shape>, M>>(
            mask: M,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: Omit<Shape, Extract<keyof Shape, keyof M>>[k]
            },
            Config,
        >;
        optional(): ZodOptional<ZodObject<Shape, Config>>;
        or<T extends SomeType>(option: T): ZodUnion<[ZodObject<Shape, Config>, T]>;
        overwrite(
            fn: (x: $InferObjectOutput<Shape>) => $InferObjectOutput<Shape>,
        ): this;
        parse(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): $InferObjectOutput<Shape>;
        parseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<$InferObjectOutput<Shape, Config["out"]>>;
        partial(): ZodObject<
            { [k in string
            | number
            | symbol]: ZodOptional<Shape[k]> },
            Config,
        >;
        partial<M extends Exactly<Mask<keyof Shape>, M>>(
            mask: M,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: k extends keyof M ? ZodOptional<Shape[k<k>]> : Shape[k]
            },
            Config,
        >;
        passthrough(): ZodObject<Shape, $loose>;
        pick<M extends Exactly<Mask<keyof Shape>, M>>(
            mask: M,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: Pick<Shape, Extract<keyof Shape, keyof M>>[k]
            },
            Config,
        >;
        pipe<
            T extends
                $ZodType<
                    any,
                    $InferObjectOutput<Shape, Config["out"]>,
                    $ZodTypeInternals<any, $InferObjectOutput<Shape, Config["out"]>>,
                >,
        >(
            target:
                | T
                | $ZodType<
                    any,
                    $InferObjectOutput<Shape, Config["out"]>,
                    $ZodTypeInternals<any, $InferObjectOutput<Shape, Config["out"]>>,
                >,
        ): ZodPipe<ZodObject<Shape, Config>, T>;
        prefault(
            def: () => $InferObjectInput<Shape>,
        ): ZodPrefault<ZodObject<Shape, Config>>;
        prefault(
            def: $InferObjectInput<Shape>,
        ): ZodPrefault<ZodObject<Shape, Config>>;
        readonly(): ZodReadonly<ZodObject<Shape, Config>>;
        refine(
            check: (arg: $InferObjectOutput<Shape>) => unknown,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<NonNullable<$ZodIssue>>;
                    message?: string;
                    params?: Record<string, any>;
                    path?: PropertyKey[];
                },
        ): this;
        register<
            R extends
                $ZodRegistry<
                    MetadataType,
                    $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
                >,
        >(
            registry: R,
            ...meta: ZodObject<Shape, Config> extends R["_schema"]
                ? undefined extends R["_meta"]
                    ? [$replace<R["_meta"], R["_schema"] & ZodObject<Shape, Config>>?]
                    : [$replace<R["_meta"], R["_schema"] & ZodObject<Shape, Config>>]
                : ["Incompatible schema"],
        ): this;
        required(): ZodObject<
            { [k in string
            | number
            | symbol]: ZodNonOptional<Shape[k]> },
            Config,
        >;
        required<M extends Exactly<Mask<keyof Shape>, M>>(
            mask: M,
        ): ZodObject<
            {
                [k in string
                | number
                | symbol]: k extends keyof M ? ZodNonOptional<Shape[k<k>]> : Shape[k]
            },
            Config,
        >;
        safeParse(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): ZodSafeParseResult<$InferObjectOutput<Shape, Config["out"]>>;
        safeParseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<ZodSafeParseResult<$InferObjectOutput<Shape, Config["out"]>>>;
        strict(): ZodObject<Shape, $strict>;
        strip(): ZodObject<Shape, $strip>;
        superRefine(
            refinement: (
                arg: $InferObjectOutput<Shape>,
                ctx: RefinementCtx<$InferObjectOutput<Shape, Config["out"]>>,
            ) => void | Promise<void>,
        ): this;
        transform<NewOut>(
            transform: (
                arg: $InferObjectOutput<Shape>,
                ctx: RefinementCtx<$InferObjectOutput<Shape, Config["out"]>>,
            ) => NewOut | Promise<NewOut>,
        ): ZodPipe<
            ZodObject<Shape, Config>,
            ZodTransform<Awaited<NewOut>, $InferObjectOutput<Shape, Config["out"]>>,
        >;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    Use .def instead.

    Use z.input<typeof schema> instead.

    _output: $InferObjectOutput<Shape, Config["out"]>

    Use z.output<typeof schema> instead.

    description?: string
    shape: Shape
    spa: (
        data: unknown,
        params?: ParseContext<$ZodIssue>,
    ) => Promise<ZodSafeParseResult<$InferObjectOutput<Shape, Config["out"]>>>
    type: "object"

    Methods

    • Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior.

      Type Parameters

      Parameters

      • schema: T

      Returns ZodObject<Shape, $catchall<T>>

    • Parameters

      Returns this

    • Returns a new instance that has been registered in z.globalRegistry with the specified description

      Parameters

      • description: string

      Returns this

    • Type Parameters

      Parameters

      • shape: U

      Returns ZodObject<
          {
              [k in string
              | number
              | symbol]: (
                  (keyof Shape & keyof U) extends never
                      ? Shape & U
                      : {
                          [K in string | number | symbol as K extends keyof U ? never : K]: Shape[K]
                      } & { [K in string
                      | number
                      | symbol]: U[K] }
              )[k]
          },
          Config,
      >

    • Returns boolean

      Try safe-parsing null (this is what isNullable does internally):

      const schema = z.string().nullable();
      const isNullable = schema.safeParse(null).success; // true
    • Returns boolean

      Try safe-parsing undefined (this is what isOptional does internally):

      const schema = z.string().optional();
      const isOptional = schema.safeParse(undefined).success; // true
    • Returns ZodEnum<{ [k in string]: { [k in string]: k }[k] }>

    • Consider z.looseObject(A.shape) instead

      Returns ZodObject<Shape, $loose>

    • Type Parameters

      Parameters

      • other: U

      Returns ZodObject<
          {
              [k in string
              | number
              | symbol]: (
                  (keyof Shape & keyof U["shape"]) extends never
                      ? Shape & U["shape"]
                      : {
                          [K in string | number | symbol as K extends keyof U["shape"]
                              ? never
                              : K]: Shape[K]
                      } & { [K in string
                      | number
                      | symbol]: U["shape"][K] }
              )[k]
          },
          U["_zod"]["config"],
      >

      Use spread syntax and the .shape property to combine two object schemas:

      const A = z.object({ a: z.string() });
      const B = z.object({ b: z.number() });

      const C = z.object({
      ...A.shape,
      ...B.shape
      });
    • Returns the metadata associated with this instance in z.globalRegistry

      Returns
          | undefined
          | {
              deprecated?: boolean;
              description?: string;
              example?: unknown;
              examples?: | unknown[]
              | { [key: string]: { value: unknown; [key: string]: unknown } };
              id?: string;
              title?: string;
              [key: string]: unknown;
          }

    • Returns a new instance that has been registered in z.globalRegistry with the specified metadata

      Parameters

      • data: {
            deprecated?: boolean;
            description?: string;
            example?: unknown;
            examples?:
                | unknown[]
                | { [key: string]: { value: unknown; [key: string]: unknown } };
            id?: string;
            title?: string;
            [key: string]: unknown;
        }

      Returns this

    • Type Parameters

      Parameters

      • mask: M

      Returns ZodObject<
          {
              [k in string
              | number
              | symbol]: Omit<Shape, Extract<keyof Shape, keyof M>>[k]
          },
          Config,
      >

    • Returns ZodObject<{ [k in string | number | symbol]: ZodOptional<Shape[k]> }, Config>

    • Type Parameters

      Parameters

      • mask: M

      Returns ZodObject<
          {
              [k in string
              | number
              | symbol]: k extends keyof M ? ZodOptional<Shape[k<k>]> : Shape[k]
          },
          Config,
      >

    • Returns ZodObject<Shape, $loose>

      Use z.looseObject() or .loose() instead.

    • Type Parameters

      Parameters

      • mask: M

      Returns ZodObject<
          {
              [k in string
              | number
              | symbol]: Pick<Shape, Extract<keyof Shape, keyof M>>[k]
          },
          Config,
      >

    • Parameters

      Returns this

    • This is the default behavior. This method call is likely unnecessary.

      Returns ZodObject<Shape, $strip>