Skip to content
Logo

T.number

A scalar. T.number and T.number.integer work bare, without .whereby(), and draw from the whole range of numbers. .integer always gives whole numbers, bounded or not.

T.number.whereby({ min: 1, max: 100 });
T.number.whereby({ min: 0, max: { value: 1, exclusive: true } }); // [0, 1)
T.number.whereby({ min: 0 }); // [0, +∞)
T.number.integer.whereby({ min: 1, max: 100 });

Leave out min or max to leave that end unbounded, the same as a bare T.number. A missing end does not default to 0. Adapters only see the ends you set.

Add a distribution to change how values spread across a bounded range. See Distributions.

T.number.integer.sequence; // 1, 2, 3, ...
T.number.integer.big; // T.bigint

See Sequences for .sequence.

.admits({ min, max, multipleOf }) changes what adapters accept without changing what is generated: wider ends, and JSON Schema's multipleOf. See .admits(...).

For numbers that never repeat, see T.unique.number.