Skip to content

max ​

The number is at most max (inclusive).

Signature ​

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

Parameters ​

ParameterTypeDescription
maxnumberMaximum value
msgMessageCustom error message. A string with {params} or a function

Error codes ​

CodeWhenDefault message
maxThe number is greater than maxMust be at most {max}

You can change the texts: see Messages & i18n.

Notes ​

Works with numbers only. For string length use maxLength.

Example ​

Rating from 1 to 5 ​

ts
pipe(number(), integer(), min(1), max(5))

See also ​