Skip to content

id

Validates a national identification number for one of 42 supported countries.

Options

OptionTypeDefaultDescription
countrystringundefinedISO 3166-1 alpha-2 country code (e.g. "BR", "DE", "ES")
messagestringlocale defaultCustom error message

Playground

Valid values by country (examples)

CountryValueNotes
BR"231.002.999-81"Brazilian CPF
DE"85055201671"German Personalausweis
ES"99999999R"Spanish DNI
FR"195017530058990"French NIR

Invalid values

ValueCountryReason
"000.000.000-00"BRAll-zeros CPF
"99999999X"ESWrong check letter

Notes

  • Empty string ("") always returns valid: true. Combine with notEmpty to require a value.
  • Unknown or omitted country returns valid: true (pass-through).
  • The playground uses country: 'US' (SSN format). Other supported countries include BR (CPF), DE, ES (DNI), FR (NIR), MX (CURP), PL (PESEL), and many more.
  • Supported countries: AR, BA, BG, BR, CH, CL, CN, CO, CZ, DK, EE, ES, FI, FR, HK, HR, ID, IE, IL, IS, KR, LT, LV, ME, MK, MX, MY, NL, NO, PE, PL, RO, RS, SE, SI, SK, SM, TH, TR, TW, UY, ZA.
  • EE (Estonia) uses the Lithuanian algorithm. SK (Slovakia) uses the Czech algorithm.

Released under the MIT License.