max
The number is at most max (inclusive).
Signature
ts
function max(max: number, msg?: Message): Action<number>Parameters
| Parameter | Type | Description |
|---|---|---|
max | number | Maximum value |
msg | Message | Custom error message. A string with {params} or a function |
Error codes
| Code | When | Default message |
|---|---|---|
max | The number is greater than max | Must 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))