Skip to main content
Documents and numbers of 14 countries, with their check digits. The constraints of each country live in a package of their own, io.github.soleworks.validity.constraints.<country>, and their messages in a block of their own: messages { brazil { cpf = "CPF inválido" } }.
Supplier.kt

Brazil · constraints.brazil

For cpf, cnh and pis, a number with all its digits the same, such as 111.111.111-11, fails.

cpf

cpf() on String Checks that the string is a Brazilian CPF with valid check digits, as 11 digits or as 000.000.000-00. cpf

cnpj

cnpj() on String Checks that the string is a Brazilian CNPJ with valid check digits, as 14 characters or as 00.000.000/0000-00. The first 12 characters can be uppercase letters, as in the alphanumeric CNPJ. cnpj

cnh

cnh() on String Checks that the string is a Brazilian CNH (driver’s license number): 11 digits with valid check digits. cnh

pis

pis() on String Checks that the string is a Brazilian PIS/PASEP/NIT with a valid check digit, as 11 digits or as 000.00000.00-0. pis

cep

cep() on String Checks that the string is a Brazilian CEP: 8 digits, with or without the dash, such as 01310-100. cep

placa

placa() on String Checks that the string is a Brazilian license plate, in the old (ABC-1234) or the Mercosul (ABC1D23) layout. Letters are uppercase, and the separator can be a dash, a space or nothing. placa

Bulgaria · constraints.bulgaria

egn

egn() on String Checks that the string is a Bulgarian EGN: 10 digits that start with a real birth date, and a valid check digit. egn

Canada · constraints.canada

sin

sin() on String Checks that the string is a Canadian SIN: 9 digits with a valid Luhn check digit, with no spaces. sin

France · constraints.france

spi

spi() on String Checks that the string is a French tax number (SPI): 13 digits with a valid check, as one block or as 00 00 000 000 000. spi

Israel · constraints.israel

teudatZehut

teudatZehut() on String Checks that the string is an Israeli Teudat Zehut number: 9 digits with a valid check digit. Shorter numbers need their leading zeros, and the whitespace around them is ignored. teudatZehut

Netherlands · constraints.netherlands

bsn

bsn() on String Checks that the string is a Dutch BSN: 9 digits that pass the eleven test. bsn

Pakistan · constraints.pakistan

cnic

cnic() on String Checks that the string is a Pakistani CNIC written as 00000-0000000-0. Whitespace around the number is ignored. cnic

Poland · constraints.poland

pesel

pesel() on String Checks that the string is a Polish PESEL: 11 digits that start with a real birth date, and a valid check digit. pesel

nip

nip() on String Checks that the string is a Polish NIP (tax number): 10 digits with a valid check digit, with no dashes. nip

Russia · constraints.russia

innIndividual

innIndividual() on String Checks that the string is the INN of a Russian individual: 12 digits with two valid check digits. innIndividual

innLegalEntity

innLegalEntity() on String Checks that the string is the INN of a Russian legal entity: 10 digits with a valid check digit. innLegalEntity

Slovenia · constraints.slovenia

davcnaStevilka

davcnaStevilka() on String Checks that the string is a Slovenian tax number (davčna številka): 8 digits, not starting with 0, with a valid check digit. davcnaStevilka

Spain · constraints.spain

Both ignore case, and the whitespace around the number.

dni

dni() on String Checks that the string is a Spanish DNI: 8 digits and the matching control letter, such as 12345678Z. dni

nie

nie() on String Checks that the string is a Spanish NIE: X, Y or Z, 7 digits and the matching control letter, such as X1234567L. nie

Thailand · constraints.thailand

nationalId

nationalId() on String Checks that the string is a Thai national ID number: 13 digits with a valid check digit, with no dashes. nationalId

Ukraine · constraints.ukraine

rnokpp

rnokpp() on String Checks that the string is a Ukrainian RNOKPP (tax number): 10 digits with a valid check digit. rnokpp

United States · constraints.unitedstates

ein

ein() on String Checks that the string is a US EIN with a prefix the IRS assigns, such as 12-3456789. The separator can be a dash, a space or nothing. ein
A document that can be of two kinds, such as a CPF or a CNPJ, is one rule with or: or { cpf(); cnpj() }.