Skip to content

integer

Validates that a field contains a whole number (positive or negative).

Options

OptionTypeDefaultDescription
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"42"Positive integer
"-42"Negative integer
"0"Zero

Invalid values

ValueReason
"3.14"Decimal number
"1e5"Scientific notation
"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.
  • For positive integers only, combine with greaterThan: { min: 0 }.

Released under the MIT License.