Skip to content

digits

Validates that a field contains only digit characters (0–9).

Options

OptionTypeDefaultDescription
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"123456"All digits
"0"Single digit

Invalid values

ValueReason
"12a456"Contains a letter
"123 456"Contains a space
"3.14"Contains a decimal point

Notes

  • Empty string ("") always returns valid: true — validators only run on non-empty values. Combine with notEmpty to require a value.
  • Does not allow spaces, dots, or signs. Use numeric or integer for those cases.

Released under the MIT License.