digits
Validates that a field contains only digit characters (0–9).
Options
| Option | Type | Default | Description |
|---|---|---|---|
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
"123456" | All digits |
"0" | Single digit |
Invalid values
| Value | Reason |
|---|---|
"12a456" | Contains a letter |
"123 456" | Contains a space |
"3.14" | Contains a decimal point |
Notes
- Empty string (
"") always returnsvalid: true— validators only run on non-empty values. Combine withnotEmptyto require a value. - Does not allow spaces, dots, or signs. Use
numericorintegerfor those cases.