Skip to content

between ​

A number from min to max inclusive.

Signature ​

ts
function between(min: number, max: number, msg?: Message): Action<number>

Parameters ​

ParameterTypeDescription
minnumberMinimum
maxnumberMaximum
msgMessageCustom error message

Error codes ​

CodeWhenDefault message
betweenThe number is out of rangeMust be between {min} and {max}

You can change the texts: see Messages & i18n.

Example ​

ts
const rating = pipe(coerce.number(), integer(), between(1, 5));

See also ​