anyNumber
Accepts any validnumber value.
This also accepts special values like NaN and Infinity. Unless you want to deliberately accept those, you’ll likely want to use the number decoder instead.
Example
number
Accepts finite numbers (can be integer or float values). ValuesNaN, or positive and negative Infinity will get rejected.
Example
integer
Accepts only finite whole numbers.Example
positiveNumber
Accepts only non-negative (zero or positive) finite numbers.Example
positiveInteger
Accepts only non-negative (zero or positive) finite whole numbers.Example
min
Accepts numbers greater than or equal to the given minimum. Defaults to thenumber decoder if none is provided. Pass a different decoder to further restrict accepted values, e.g. min(0, integer).
Parameters
min- The minimum allowed value (inclusive)decoder- Optional base decoder (defaults tonumber)
Example
max
Accepts numbers less than or equal to the given maximum. Defaults to thenumber decoder if none is provided. Pass a different decoder to further restrict accepted values, e.g. max(100, integer).
Parameters
max- The maximum allowed value (inclusive)decoder- Optional base decoder (defaults tonumber)
Example
between
Accepts numbers within the given range (bounds are inclusive). Defaults to thenumber decoder if none is provided. Pass a different decoder to further restrict accepted values, e.g. between(1, 10, integer).
Parameters
min- The minimum allowed value (inclusive)max- The maximum allowed value (inclusive)decoder- Optional base decoder (defaults tonumber)
