Skip to main content

Function: max()

max(maximum, errorMessage?): Validator<number, number, string>

Defined in: validation/validators/index.ts:213

Validates number is less than or equal to maximum.

Parameters

maximum

number

Maximum value (inclusive)

errorMessage?

string

Custom error message (optional)

Returns

Validator<number, number, string>

Validator that checks maximum value

Example

max(100)(50) // => Valid(50)
max(100)(150) // => Invalid(['Must be at most 100'])