Skip to content

phone

Validates a phone number for a specified country.

Options

OptionTypeDefaultDescription
countrystringundefinedISO 3166-1 alpha-2 country code
messagestringlocale defaultCustom error message

Playground

Valid values by country (examples)

CountryValueNotes
US"+1 (555) 123-4567"US number
BR"(11) 98765-4321"Brazilian mobile
DE"030 12345678"German landline
GB"07700 900123"UK mobile

Invalid values

ValueCountryReason
"123"USToo short
"abc-def-ghij"USNon-numeric

Notes

  • Empty string ("") always returns valid: true. Combine with notEmpty to require a value.
  • Without country, accepts any string that looks like a phone number (loose validation).
  • Supported countries: AE, BG, BR, CN, CZ, DE, DK, ES, FR, GB, IN, MA, NL, PK, RO, RU, SK, TH, US, VE.

Released under the MIT License.