Skip to content

between ​

Validates that a numeric value is between a minimum and maximum.

Options ​

OptionTypeDefaultDescription
minnumberrequiredMinimum allowed value
maxnumberrequiredMaximum allowed value
inclusivebooleantrueIf true, min and max themselves are valid
messagestringlocale defaultCustom error message

Playground ​

Valid values ​

ValueNotes
"18"Equal to min (inclusive=true)
"50"Between min and max
"99"Equal to max (inclusive=true)

Invalid values ​

ValueReason
"17"Below min
"100"Above max
"18"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.
  • inclusive: false means min and max themselves are invalid.

Released under the MIT License.