Skip to content

step

Validates that a number is a multiple of a step value from a base.

Options

OptionTypeDefaultDescription
stepnumber1The step increment
baseValuenumber0The base value from which multiples are counted
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"5"Multiple of 5 from base 0
"100"Multiple of 5
"0"Base value itself

Invalid values

ValueReason
"3"Not a multiple of 5
"5.5"Not a multiple of step=1 (default)

Notes

  • Empty string ("") always returns valid: true. Combine with notEmpty to require a value.
  • baseValue shifts the valid range: with baseValue: 1, step: 2, valid values are 1, 3, 5, 7…

Released under the MIT License.