Skip to content

lessThan

Validates that a numeric value is less than (or equal to) a maximum.

Options

OptionTypeDefaultDescription
maxnumberrequiredMaximum allowed value
inclusivebooleantrueIf true, the maximum value itself is valid
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"100"Equal to max (inclusive=true)
"50"Below max

Invalid values

ValueReason
"101"Above max
"100"Equal to max when inclusive: false
"abc"Not a number

Notes

  • Empty string ("") always returns valid: true — validators only run on non-empty values. Combine with notEmpty to require a value.
  • With inclusive: true (default), the boundary value itself is valid.

Released under the MIT License.