Skip to main content

coerceBigInt()

coerceBigInt(message?): BigIntConstraint

Coerce BigInt schema - converts values to bigint with constraints.

Handles conversion from number, string, boolean, and other types to BigInt. Returns the coerced value directly for optimal performance.


Parametersโ€‹

message?: stringโ€‹

Custom error message


Returns: BigIntConstraintโ€‹

Schema that converts to bigint with chainable constraints.


Sinceโ€‹

2.0.0


Exampleโ€‹

// Basic coercion
coerceBigInt()

// With constraints
coerceBigInt().min(0n).max(100n)
coerceBigInt().positive()