integer
Validates that a field contains a whole number (positive or negative).
Options
| Option | Type | Default | Description |
|---|---|---|---|
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
"42" | Positive integer |
"-42" | Negative integer |
"0" | Zero |
Invalid values
| Value | Reason |
|---|---|
"3.14" | Decimal number |
"1e5" | Scientific notation |
"abc" | Not a number |
Notes
- Empty string (
"") always returnsvalid: true— validators only run on non-empty values. Combine withnotEmptyto require a value. - For positive integers only, combine with
greaterThan: { min: 0 }.