bupkis
    Preparing search index...

    Interface ZodJSONSchema

    interface ZodJSONSchema {
        _zod: ZodJSONSchemaInternals;
        options: [
            z.ZodString,
            z.ZodNumber,
            z.ZodBoolean,
            z.ZodNull,
            z.ZodArray<ZodJSONSchema>,
            z.ZodRecord<z.ZodString, ZodJSONSchema>,
        ];
        def: $ZodUnionDef<
            [
                z.ZodString,
                z.ZodNumber,
                z.ZodBoolean,
                z.ZodNull,
                z.ZodArray<ZodJSONSchema>,
                z.ZodRecord<z.ZodString, ZodJSONSchema>,
            ],
        >;
        type: "union";
        _def: $ZodUnionDef<
            [
                z.ZodString,
                z.ZodNumber,
                z.ZodBoolean,
                z.ZodNull,
                z.ZodArray<ZodJSONSchema>,
                z.ZodRecord<z.ZodString, ZodJSONSchema>,
            ],
        >;
        _output:
            | null
            | string
            | number
            | boolean
            | Record<string, JSONType>
            | JSONType[];
        _input:
            | null
            | string
            | number
            | boolean
            | Record<string, JSONType>
            | JSONType[];
        spa: (
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ) => Promise<ZodSafeParseResult<JSONType>>;
        description?: string;
        "~standard": $ZodStandardSchema<ZodJSONSchema>;
        check(...checks: (CheckFn<JSONType> | z.core.$ZodCheck<JSONType>)[]): this;
        clone(
            def?: $ZodUnionDef<
                [
                    z.ZodString,
                    z.ZodNumber,
                    z.ZodBoolean,
                    z.ZodNull,
                    z.ZodArray<ZodJSONSchema>,
                    z.ZodRecord<z.ZodString, ZodJSONSchema>,
                ],
            >,
            params?: { parent: boolean },
        ): this;
        register<
            R extends
                $ZodRegistry<
                    MetadataType,
                    z.core.$ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
                >,
        >(
            registry: R,
            ...meta: ZodJSONSchema extends R["_schema"]
                ? undefined extends R["_meta"]
                    ? [$replace<R["_meta"], R["_schema"] & ZodJSONSchema>?]
                    : [$replace<R["_meta"], R["_schema"] & ZodJSONSchema>]
                : ["Incompatible schema"],
        ): this;
        brand<T extends PropertyKey = PropertyKey>(
            value?: T,
        ): PropertyKey extends T ? ZodJSONSchema : $ZodBranded<ZodJSONSchema, T>;
        parse(data: unknown, params?: ParseContext<$ZodIssue>): JSONType;
        safeParse(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): ZodSafeParseResult<JSONType>;
        parseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<JSONType>;
        safeParseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<ZodSafeParseResult<JSONType>>;
        encode(data: JSONType, params?: ParseContext<$ZodIssue>): JSONType;
        decode(data: JSONType, params?: ParseContext<$ZodIssue>): JSONType;
        encodeAsync(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): Promise<JSONType>;
        decodeAsync(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): Promise<JSONType>;
        safeEncode(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): ZodSafeParseResult<JSONType>;
        safeDecode(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): ZodSafeParseResult<JSONType>;
        safeEncodeAsync(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): Promise<ZodSafeParseResult<JSONType>>;
        safeDecodeAsync(
            data: JSONType,
            params?: ParseContext<$ZodIssue>,
        ): Promise<ZodSafeParseResult<JSONType>>;
        refine(
            check: (arg: JSONType) => unknown,
            params?:
                | string
                | {
                    abort?: boolean;
                    when?: (payload: ParsePayload) => boolean;
                    path?: PropertyKey[];
                    params?: Record<string, any>;
                    error?: string | $ZodErrorMap<NonNullable<$ZodIssue>>;
                    message?: string;
                },
        ): this;
        superRefine(
            refinement: (
                arg: JSONType,
                ctx: $RefinementCtx<JSONType>,
            ) => void | Promise<void>,
        ): this;
        overwrite(fn: (x: JSONType) => JSONType): this;
        optional(): z.ZodOptional<ZodJSONSchema>;
        nonoptional(
            params?:
                | string
                | {
                    error?: string
                    | $ZodErrorMap<$ZodIssueInvalidType<unknown>>;
                    message?: string;
                },
        ): z.ZodNonOptional<ZodJSONSchema>;
        nullable(): z.ZodNullable<ZodJSONSchema>;
        nullish(): z.ZodOptional<z.ZodNullable<ZodJSONSchema>>;
        default(def: JSONType): z.ZodDefault<ZodJSONSchema>;
        default(def: () => JSONType): z.ZodDefault<ZodJSONSchema>;
        prefault(def: () => JSONType): z.ZodPrefault<ZodJSONSchema>;
        prefault(def: JSONType): z.ZodPrefault<ZodJSONSchema>;
        array(): z.ZodArray<ZodJSONSchema>;
        or<T extends SomeType>(option: T): z.ZodUnion<[ZodJSONSchema, T]>;
        and<T extends SomeType>(incoming: T): z.ZodIntersection<ZodJSONSchema, T>;
        transform<NewOut>(
            transform: (
                arg: JSONType,
                ctx: $RefinementCtx<JSONType>,
            ) => NewOut | Promise<NewOut>,
        ): z.ZodPipe<ZodJSONSchema, z.ZodTransform<Awaited<NewOut>, JSONType>>;
        catch(def: JSONType): z.ZodCatch<ZodJSONSchema>;
        catch(def: (ctx: $ZodCatchCtx) => JSONType): z.ZodCatch<ZodJSONSchema>;
        pipe<
            T extends
                z.core.$ZodType<any, JSONType, $ZodTypeInternals<any, JSONType>>,
        >(
            target:
                | T
                | z.core.$ZodType<any, JSONType, $ZodTypeInternals<any, JSONType>>,
        ): z.ZodPipe<ZodJSONSchema, T>;
        readonly(): z.ZodReadonly<ZodJSONSchema>;
        describe(description: string): this;
        meta(): | undefined
        | {
            id?: string;
            title?: string;
            description?: string;
            deprecated?: boolean;
            [key: string]: unknown;
        };
        meta(
            data: {
                id?: string;
                title?: string;
                description?: string;
                deprecated?: boolean;
                [key: string]: unknown;
            },
        ): this;
        isOptional(): boolean;
        isNullable(): boolean;
    }

    Hierarchy

    Index

    Properties

    options: [
        z.ZodString,
        z.ZodNumber,
        z.ZodBoolean,
        z.ZodNull,
        z.ZodArray<ZodJSONSchema>,
        z.ZodRecord<z.ZodString, ZodJSONSchema>,
    ]
    def: $ZodUnionDef<
        [
            z.ZodString,
            z.ZodNumber,
            z.ZodBoolean,
            z.ZodNull,
            z.ZodArray<ZodJSONSchema>,
            z.ZodRecord<z.ZodString, ZodJSONSchema>,
        ],
    >
    type: "union"
    _def: $ZodUnionDef<
        [
            z.ZodString,
            z.ZodNumber,
            z.ZodBoolean,
            z.ZodNull,
            z.ZodArray<ZodJSONSchema>,
            z.ZodRecord<z.ZodString, ZodJSONSchema>,
        ],
    >

    Use .def instead.

    _output:
        | null
        | string
        | number
        | boolean
        | Record<string, JSONType>
        | JSONType[]

    Use z.output<typeof schema> instead.

    _input: null | string | number | boolean | Record<string, JSONType> | JSONType[]

    Use z.input<typeof schema> instead.

    spa: (
        data: unknown,
        params?: ParseContext<$ZodIssue>,
    ) => Promise<ZodSafeParseResult<JSONType>>
    description?: string

    Methods

    • Parameters

      • check: (arg: JSONType) => unknown
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                when?: (payload: ParsePayload) => boolean;
                path?: PropertyKey[];
                params?: Record<string, any>;
                error?: string | $ZodErrorMap<NonNullable<$ZodIssue>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              when?: (payload: ParsePayload) => boolean;
              path?: PropertyKey[];
              params?: Record<string, any>;
              error?: string | $ZodErrorMap<NonNullable<$ZodIssue>>;
              message?: string;
          }
          • Optionalabort?: boolean

            If true, no later checks will be executed if this check fails. Default false.

          • Optionalwhen?: (payload: ParsePayload) => boolean

            If provided, this check will only be executed if the function returns true. Defaults to payload => z.util.isAborted(payload).

          • Optionalpath?: PropertyKey[]
          • Optionalparams?: Record<string, any>
          • Optionalerror?: string | $ZodErrorMap<NonNullable<$ZodIssue>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      Returns this

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

      Parameters

      • description: string

      Returns this

    • Returns the metadata associated with this instance in z.globalRegistry

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

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

      Parameters

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

      Returns this

    • 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 boolean

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

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