Type Formats
BigInt Formats
Signed and unsigned 64-bit ranges and sign checks for bigint values.
Named BigInt Formats
Each format is a TF.BigInt with its params set, and has a builder named in lowercase (TF.bigInt64(), TF.bigPositive()). For your own bounds, see Custom BigInt Formats.
const isBigInt64 = createValidateFn<TF.BigInt64>();
const isBigUInt64 = createValidateFn<TF.BigUInt64>();
const isBigPositive = createValidateFn<TF.BigPositive>();
isBigInt64(-9223372036854775808n); // true
isBigInt64(9223372036854775808n); // false, one over the limit
isBigUInt64(-1n); // false
isBigPositive(0n); // true, zero is included
| Format | Accepts |
|---|---|
TF.BigPositive, TF.BigPositiveInt | >= 0n |
TF.BigNegative, TF.BigNegativeInt | <= 0n |
TF.BigInt64 | a value that fits a signed 64-bit integer |
TF.BigUInt64 | a value that fits an unsigned 64-bit integer |
Custom BigInt Formats
Use TF.BigInt with your own bounds when no named format fits.
type AccountId = TF.BigInt<{min: 1n; max: 999_999_999_999n}>;
const isAccountId = createValidateFn<AccountId>();
isAccountId(42n); // true
isAccountId(0n); // false, under 1n
Bounds on a bigint format are
bigint literals: write TF.BigInt<{min: 0n}>, not {min: 0}.