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

    Interface ZodNumber

    interface ZodNumber {
        _def: $ZodNumberDef;
        _input: number;
        _output: number;
        _zod: $ZodNumberInternals;
        "~standard": $ZodStandardSchema<ZodNumber>;
        def: $ZodNumberDef;
        description?: string;
        format: null | string;
        isFinite: boolean;
        isInt: boolean;
        maxValue: null | number;
        minValue: null | number;
        spa: (
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ) => Promise<ZodSafeParseResult<number>>;
        type: "number";
        and<T extends SomeType>(incoming: T): ZodIntersection<ZodNumber, T>;
        array(): ZodArray<ZodNumber>;
        brand<T extends PropertyKey = PropertyKey>(
            value?: T,
        ): PropertyKey extends T ? ZodNumber : $ZodBranded<ZodNumber, T>;
        catch(def: number): ZodCatch<ZodNumber>;
        catch(def: (ctx: $ZodCatchCtx) => number): ZodCatch<ZodNumber>;
        check(...checks: (CheckFn<number> | $ZodCheck<number>)[]): this;
        clone(def?: $ZodNumberDef, params?: { parent: boolean }): this;
        default(def: number): ZodDefault<ZodNumber>;
        default(def: () => number): ZodDefault<ZodNumber>;
        describe(description: string): this;
        finite(params?: unknown): this;
        gt(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                    message?: string;
                },
        ): this;
        gte(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                    message?: string;
                },
        ): this;
        int(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: | string
                    | $ZodErrorMap<
                        NonNullable<
                            | $ZodIssueInvalidType<unknown>
                            | $ZodIssueTooBig<"number">
                            | $ZodIssueTooSmall<"number">,
                        >,
                    >;
                    message?: string;
                },
        ): this;
        isNullable(): boolean;
        isOptional(): boolean;
        lt(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                    message?: string;
                },
        ): this;
        lte(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                    message?: string;
                },
        ): this;
        max(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                    message?: string;
                },
        ): this;
        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;
        min(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                    message?: string;
                },
        ): this;
        multipleOf(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
                    message?: string;
                },
        ): this;
        negative(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                    message?: string;
                },
        ): this;
        nonnegative(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                    message?: string;
                },
        ): this;
        nonoptional(
            params?:
                | string
                | {
                    error?: string
                    | $ZodErrorMap<$ZodIssueInvalidType<unknown>>;
                    message?: string;
                },
        ): ZodNonOptional<ZodNumber>;
        nonpositive(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                    message?: string;
                },
        ): this;
        nullable(): ZodNullable<ZodNumber>;
        nullish(): ZodOptional<ZodNullable<ZodNumber>>;
        optional(): ZodOptional<ZodNumber>;
        or<T extends SomeType>(option: T): ZodUnion<[ZodNumber, T]>;
        overwrite(fn: (x: number) => number): this;
        parse(data: unknown, params?: ParseContext<$ZodIssue>): number;
        parseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<number>;
        pipe<T extends $ZodType<any, number, $ZodTypeInternals<any, number>>>(
            target: T | $ZodType<any, number, $ZodTypeInternals<any, number>>,
        ): ZodPipe<ZodNumber, T>;
        positive(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                    message?: string;
                },
        ): this;
        prefault(def: () => number): ZodPrefault<ZodNumber>;
        prefault(def: number): ZodPrefault<ZodNumber>;
        readonly(): ZodReadonly<ZodNumber>;
        refine(
            check: (arg: number) => 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: ZodNumber extends R["_schema"]
                ? undefined extends R["_meta"]
                    ? [$replace<R["_meta"], R["_schema"] & ZodNumber>?]
                    : [$replace<R["_meta"], R["_schema"] & ZodNumber>]
                : ["Incompatible schema"],
        ): this;
        safe(
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: | string
                    | $ZodErrorMap<
                        NonNullable<
                            | $ZodIssueInvalidType<unknown>
                            | $ZodIssueTooBig<"number">
                            | $ZodIssueTooSmall<"number">,
                        >,
                    >;
                    message?: string;
                },
        ): this;
        safeParse(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): ZodSafeParseResult<number>;
        safeParseAsync(
            data: unknown,
            params?: ParseContext<$ZodIssue>,
        ): Promise<ZodSafeParseResult<number>>;
        step(
            value: number,
            params?:
                | string
                | {
                    abort?: boolean;
                    error?: string
                    | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
                    message?: string;
                },
        ): this;
        superRefine(
            refinement: (
                arg: number,
                ctx: RefinementCtx<number>,
            ) => void | Promise<void>,
        ): this;
        transform<NewOut>(
            transform: (
                arg: number,
                ctx: RefinementCtx<number>,
            ) => NewOut | Promise<NewOut>,
        ): ZodPipe<ZodNumber, ZodTransform<Awaited<NewOut>, number>>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    Use .def instead.

    _input: number

    Use z.input<typeof schema> instead.

    _output: number

    Use z.output<typeof schema> instead.

    description?: string
    format: null | string
    isFinite: boolean

    Number schemas no longer accept infinite values, so this always returns true.

    isInt: boolean

    Check the format property instead.

    maxValue: null | number
    minValue: null | number
    spa: (
        data: unknown,
        params?: ParseContext<$ZodIssue>,
    ) => Promise<ZodSafeParseResult<number>>
    type: "number"

    Methods

    • Parameters

      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

    • Parameters

      • Optionalparams: unknown

      Returns this

      In v4 and later, z.number() does not allow infinite values by default. This is a no-op.

    • Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Identical to .min()

      Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Consider z.int() instead. This API is considered legacy; it will never be removed but a better alternative exists.

      Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: | string
                | $ZodErrorMap<
                    NonNullable<
                        | $ZodIssueInvalidType<unknown>
                        | $ZodIssueTooBig<"number">
                        | $ZodIssueTooSmall<"number">,
                    >,
                >;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?:
                  | string
                  | $ZodErrorMap<
                      NonNullable<
                          | $ZodIssueInvalidType<unknown>
                          | $ZodIssueTooBig<"number">
                          | $ZodIssueTooSmall<"number">,
                      >,
                  >;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?:
                | string
                | $ZodErrorMap<
                    NonNullable<
                        | $ZodIssueInvalidType<unknown>
                        | $ZodIssueTooBig<"number">
                        | $ZodIssueTooSmall<"number">,
                    >,
                >
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

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

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Identical to .max()

      Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • 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

    • Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooBig<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

      • fn: (x: number) => number

      Returns this

    • Type Parameters

      • T extends $ZodType<any, number, $ZodTypeInternals<any, number>>

      Parameters

      • target: T | $ZodType<any, number, $ZodTypeInternals<any, number>>

      Returns ZodPipe<ZodNumber, T>

    • Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueTooSmall<Numeric>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

    • Parameters

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

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

          • Optionalerror?: string | $ZodErrorMap<NonNullable<$ZodIssue>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

          • Optionalparams?: Record<string, any>
          • Optionalpath?: PropertyKey[]

      Returns this

    • Type Parameters

      Parameters

      • registry: R
      • ...meta: ZodNumber extends R["_schema"]
            ? undefined extends R["_meta"]
                ? [$replace<R["_meta"], R["_schema"] & ZodNumber>?]
                : [$replace<R["_meta"], R["_schema"] & ZodNumber>]
            : ["Incompatible schema"]

      Returns this

    • Parameters

      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: | string
                | $ZodErrorMap<
                    NonNullable<
                        | $ZodIssueInvalidType<unknown>
                        | $ZodIssueTooBig<"number">
                        | $ZodIssueTooSmall<"number">,
                    >,
                >;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?:
                  | string
                  | $ZodErrorMap<
                      NonNullable<
                          | $ZodIssueInvalidType<unknown>
                          | $ZodIssueTooBig<"number">
                          | $ZodIssueTooSmall<"number">,
                      >,
                  >;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?:
                | string
                | $ZodErrorMap<
                    NonNullable<
                        | $ZodIssueInvalidType<unknown>
                        | $ZodIssueTooBig<"number">
                        | $ZodIssueTooSmall<"number">,
                    >,
                >
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

      This is now identical to .int(). Only numbers in the safe integer range are accepted.

    • Parameters

      • value: number
      • Optionalparams:
            | string
            | {
                abort?: boolean;
                error?: string
                | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
                message?: string;
            }
        • string
        • {
              abort?: boolean;
              error?: string | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>;
              message?: string;
          }
          • Optionalabort?: boolean

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

          • Optionalerror?: string | $ZodErrorMap<$ZodIssueNotMultipleOf<number | bigint>>
          • Optionalmessage?: string

            This parameter is deprecated. Use error instead.

      Returns this

      Use .multipleOf() instead.

    • Parameters

      • refinement: (arg: number, ctx: RefinementCtx<number>) => void | Promise<void>

      Returns this

      Use .check() instead.