Skip to content

@pcvl/schema / coerceToBigint

Function: coerceToBigint() ​

ts
function coerceToBigint(value): unknown;

Defined in: coercions.ts:84

The conversion pvl.bigint().coerce() applies before its own check: string and number inputs go through native BigInt(). An input BigInt() refuses — a malformed string, or a number with a fractional part — is handed through untouched and rejected by the bigint check rather than throwing.

Parameters ​

value ​

unknown

Returns ​

unknown

Example ​

ts
import { coerceToBigint } from '@pcvl/schema';

coerceToBigint('42'); // 42n
coerceToBigint(7); // 7n
coerceToBigint('12.5'); // '12.5' — unchanged, and so still not a bigint