Numbers
should().number(x) verifies a number (or null/undefined — see Concepts for the definedness rules).
Equality and proximity
should().number(5).equals(5); // ok
should().number(5).equals(5.0000001); // throws '5 doesn't equal 5.0000001.'
should().number(5.8).approximately(5.4, 0.5); // ok — |5.8 − 5.4| < 0.5
should().number(5.8).approximately(6.0, 0.1); // throws
approximately(expected, precision) passes when the absolute difference is strictly less than precision — the check for floats and computed values.
Comparisons
should().number(5).greater(3); // ok — 5 > 3
should().number(5).greaterOrEqual(5); // ok — inclusive
should().number(5).less(10);
should().number(5).lessOrEqual(5);
Sign
should().number(5).positive(); // > 0
should().number(-2).negative(); // < 0
should().number(0).positive(); // throws '0 is not positive.'
Ranges
should().number(5).inRange(3, 9); // ok
should().number(5).inRange(5, 10); // throws — bounds are exclusive
should().number(5).inRange(0, 5); // throws
inRange(min, max) means strictly min < x < max. For inclusive edges combine greaterOrEqual/lessOrEqual in one chain.
Negation
not flips any of the checks, with mirrored messages:
should().number(5).not.greater(10); // ok — 5 is not greater than 10
should().number(5).not.positive(); // throws '5 is positive, but should not.'
Signatures and messages
The compact table lives in API reference — Number verifier. Related recipes: Cookbook.
02 сентября 2026