Skip to main content

Basic Usage

Type Signature

string | $ZodBigIntParams
Optional error message (string) or configuration object

Comparison Methods

.gt()

Greater than (exclusive).
bigint
required
Exclusive minimum value
string | $ZodCheckGreaterThanParams
Custom error message

.gte() / .min()

Greater than or equal (inclusive). .min() is an alias for .gte().
bigint
required
Inclusive minimum value
string | $ZodCheckGreaterThanParams
Custom error message

.lt()

Less than (exclusive).
bigint
required
Exclusive maximum value
string | $ZodCheckLessThanParams
Custom error message

.lte() / .max()

Less than or equal (inclusive). .max() is an alias for .lte().
bigint
required
Inclusive maximum value
string | $ZodCheckLessThanParams
Custom error message

Sign Validations

.positive()

Requires bigint to be greater than zero.
string | $ZodCheckGreaterThanParams
Custom error message

.negative()

Requires bigint to be less than zero.
string | $ZodCheckLessThanParams
Custom error message

.nonnegative()

Requires bigint to be greater than or equal to zero.
string | $ZodCheckGreaterThanParams
Custom error message

.nonpositive()

Requires bigint to be less than or equal to zero.
string | $ZodCheckLessThanParams
Custom error message

Multiple Of

.multipleOf()

Requires bigint to be a multiple of a given value.
bigint
required
The divisor
string | $ZodCheckMultipleOfParams
Custom error message

Properties

.minValue

Returns the minimum value constraint, or null if not set.

.maxValue

Returns the maximum value constraint, or null if not set.

.format

Returns the format string if set, or null.

Specialized BigInt Formats

Use these for specific 64-bit integer types:

z.int64()

Signed 64-bit integer.
string | $ZodBigIntFormatParams
Optional error message

z.uint64()

Unsigned 64-bit integer.
string | $ZodBigIntFormatParams
Optional error message

Use Cases

BigInt is useful for:
  • Large integers beyond Number.MAX_SAFE_INTEGER (2^53 - 1)
  • Precise integer arithmetic
  • Cryptographic operations
  • Working with blockchain/cryptocurrency values
  • Database IDs (e.g., Twitter snowflake IDs)

Chaining

All methods return this, enabling chaining:

TypeScript Type

See Also