Attest.DataAnnotations
1.0.0
See the version list below for details.
dotnet add package Attest.DataAnnotations --version 1.0.0
NuGet\Install-Package Attest.DataAnnotations -Version 1.0.0
<PackageReference Include="Attest.DataAnnotations" Version="1.0.0" />
<PackageVersion Include="Attest.DataAnnotations" Version="1.0.0" />
<PackageReference Include="Attest.DataAnnotations" />
paket add Attest.DataAnnotations --version 1.0.0
#r "nuget: Attest.DataAnnotations, 1.0.0"
#:package Attest.DataAnnotations@1.0.0
#addin nuget:?package=Attest.DataAnnotations&version=1.0.0
#tool nuget:?package=Attest.DataAnnotations&version=1.0.0
Attest
Validates national identification numbers, tax identification numbers, VAT codes and postal codes for 80+ countries.
Attest started as a fork of CountryValidator by Anghel Valentin, which has had no release since 1.1.3 and a number of open validation bugs. The country rules and coverage come from that project; see CHANGELOG.md for what has been fixed since, and NOTICE for attribution.
Install
Install-Package Attest
Install-Package Attest.DataAnnotations
Use
using Attest;
var validator = new CountryValidator();
ValidationResult result = validator.ValidateIndividualTaxCode("93051822361", Country.BE);
if (!result.IsValid)
{
Console.WriteLine(result.ErrorMessage);
}
Asking by category
When you do not want to name a method — "is this any business identifier for this country?" — ask by kind:
using Attest;
var validator = new CountryValidator();
IdentifierResult result = validator.Validate(value, Country.BE, IdentifierKind.Business);
if (result.IsValid && !result.IsAmbiguous)
{
// definitely a company number or a VAT number
}
IdentifierKind is a flags enum: PersonalId, PersonalTaxCode, CompanyNumber, Vat,
PostalCode, plus the combinations Person, Business and Any (the default, which covers
personal and business identifiers but not postal codes).
Two things the result tells you that a plain boolean cannot:
IsAmbiguous— a few countries issue one number that serves as both a personal and a business identifier. Armenia (the 8 digit ՀՎՀՀ, whose digits carry no meaning by the State Revenue Committee's own account) and Nigeria are the two here, and in Russia a sole trader files VAT under his personal number, so that one number is both. There, a value asked about as a business identifier can be valid and indistinguishable at the same time, and the flag says so instead of guessing.Supports(country, kind)— whether the country has a rule for that kind at all. A kind with no rule reports every value invalid, which is not a verdict on the value. 33 of the 435 country/kind pairs in this library have no rule.
Matched lists every kind the value is valid as, and Details carries the individual
ValidationResult for each kind that was evaluated.
Each country also has its own validator class in Attest.Countries, if you want to skip the
dispatch:
using Attest.Countries;
bool valid = new BelgiumValidator().ValidateVAT("BE0428759497").IsValid;
Using Data Annotations
[HttpPost]
public IActionResult ValidateSSN([Required, SSNAttribute(Country.US)] string ssn)
{
if (!ModelState.IsValid)
{
return BadRequest();
}
return Ok();
}
Supported Countries
| Supported Country | Alpha Code 2 | National Identification Number Name | VAT Code | Entity code | Postal Code |
|---|---|---|---|---|---|
| Andorra | AD | NRT (Número de Registre Tributari, Andorra tax number) | NRT (Número de Registre Tributari, Andorra tax number) | NRT (Número de Registre Tributari, Andorra tax number) | ✔️ |
| United Arab Emirates | AE | ❌ | ❌ | ❌ | |
| Albania | AL | Identity Number - Numri i Identitetit (NID) | NIPT (Numri i Identifikimit për Personin e Tatueshëm, Albanian VAT number). | NIPT | ✔️ |
| Armenia | AM | TIN Number | TIN Number | TIN Number | ✔️ |
| Argentina | AR | DNI number | VAT/IVA/CUIT | CUIT | ✔️ |
| Austria | AT | Versicherungsnummer (VNR, SVNR, VSNR) | UID (Umsatzsteuer-Identifikationsnummer) | ✔️ | |
| Australia | AU | TFN | ABN | ABN/ACN/TFN | ✔️ |
| Azerbaijan | AZ | PIN - Personal Identification Number | VÖEN/TIN Number | VÖEN/TIN Number | ✔️ |
| Bosnia | BA | Unique Master Citizen Number JMBG | ❌ | ✔️ | |
| Belgium | BE | Rijksregisternummer | BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number). | ✔️ | |
| Bulgaria | BG | Edinen grazhdanski nomer (EGN) | Идентификационен номер по ДДС | ✔️ | |
| Bahrain | BH | Social security number | ❌ | ❌ | ✔️ |
| Bolivia | BO | CI Number | Número de Identificación Tributaria | Número de Identificación Tributaria | ✔️ |
| Brazil | BR | CPF | Brazil Cadastro Nacional da Pessoa Juridica (CNPJ) | Brazil Cadastro Nacional da Pessoa Juridica (CNPJ) | ✔️ |
| Belarus | BY | Payer's account number (UNP) | Payer's account number (UNP) | Payer's account number (UNP) | ✔️ |
| Canada | CA | SIN Number | Business Number | Business Number | ✔️ |
| Chile | CL | National Tax Number (RUN/RUT) | National Tax Number (RUN/RUT) | National Tax Number (RUN/RUT) | ✔️ |
| China | CN | Social Number (15 digits and 18 digits) | ❌ | Business Number | ✔️ |
| Colombia | CO | NIT (Número De Identificación Tributaria, Colombian identity code) | VAT | RUT (Registro Unico Tributario) | ✔️ |
| Costa Rica | CR | CPF (Cédula de Persona Física,physical person ID number)/CR(Cédula de Residencia) | CPJ | CPJ | ✔️ |
| Cuba | CU | NI (Número de identidad) | ❌ | ❌ | ✔️ |
| Croatia | HR | OIB (Osobni identifikacijski broj, Croatian identification number) | OIB (Osobni identifikacijski broj, Croatian identification number) | OIB (Osobni identifikacijski broj) | ✔️ |
| Cyprus | CY | Identity Number | ΦΠΑ | ✔️ | |
| Czechia | CZ | Rodné Císlo (RČ) | Danove Identifikacni Cislo (DIC/VAT) | ✔️ | |
| Denmark | DK | Det Centrale Personregister (CPR) | Momsregistreringsnummer (CVR/VAT) | ✔️ | |
| Dominican Republic | DO | Cedula | RNC (Registro Nacional del Contribuyente) | RNC (Registro Nacional del Contribuyente) | ✔️ |
| Ecuador | EC | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | ✔️ |
| Estonia | EE | Personal Id - Isikukood | Kaibemaksukohuslase (KMKR) | Registrikood (Estonian organisation registration code) | ✔️ |
| Finland | FI | Henkilötunnus (HETU) | Arvonlisaveronumero (ALV) | Arvonlisaveronumero (ALV) | ✔️ |
| Faroe Islands | FO | P-number | V-number | V-number | ✔️ |
| France | FR | INSEE/NIR (French personal identification number) | Taxe sur la Valeur Ajoutee (TVA) | SIREN | ✔️ |
| Germany | DE | Steueridentifikationsnummer | Umsatzsteur Identifikationnummer (VAT) | Steuernummer | ✔️ |
| Greece | GR | AMKA (Αριθμός Μητρώου Κοινωνικής Ασφάλισης, Greek social security number) | VAT Number (FPA) | VAT Number (FPA) | ✔️ |
| Great Britain | GB | NINO or NHS | VAT Reg No | Value added tax registration number | ✔️ |
| Guatemala | GT | ❌ | NIT | NIT (Número de Identificación Tributaria) | ✔️ |
| Hong Kong | HK | Social number | ❌ | ❌ | ❌ |
| Hungary | HU | Szemelyi Szam Ellenorzese | Kozossegi Adoszam (ANUM) | Cegjegyzekszam Ellenorzese | ✔️ |
| Indonesia | ID | NPWP | NPWP - Nomor Pokok Wajib Pajak | NPWP | ✔️ |
| Ireland | IE | PPS No (Personal Public Service Number, Irish personal number). | Irish Tax Reference Number (VAT) | ✔️ | |
| Israel | IL | ✔️ | |||
| India | IN | PAN (Permanent Account Number) | VAT TIN / CST TIN | PAN (Permanent Account Number) | ✔️ |
| Iceland | IS | Kennitala | Virdisaukaskattsnumer (VSK) | Kennitala | ✔️ |
| Italy | IT | Codice fiscale - Fiscal Code | Partita IVA | ✔️ | |
| Japan | JP | Japan My Number | Japan My Number | CN hōjin bangō, Japanese Corporate Number | ✔️ |
| Korea | KR | Resident Registration Number (RRN) | ❌ | ❌ | ✔️ |
| Kazakhstan | KZ | PIN | BIN | BIN БСН – бизнес-сәйкестендіру нөмірі | ✔️ |
| Latvia | LV | Personal Code - Personas kods | PVN (Pievienotās vērtības nodokļa, Latvian VAT number) | PVN (Pievienotās vērtības nodokļa, Latvian VAT number) | ✔️ |
| Lithuania | LT | Personal Code - Asmens kodas | PVM (Pridėtinės vertės mokestis mokėtojo kodas, Lithuanian VAT number) | ✔️ | |
| Luxembourg | LU | Personal identification code (PIC) | TVA (taxe sur la valeur ajoutée, Luxembourgian VAT number) | ✔️ | |
| Malta | MT | Identity Card Number | VAT Number | ✔️ | |
| Monaco | MC | ❌ | VAT Number | VAT Number | ✔️ |
| Moldova | MD | IDNP (Identification Number of Person) | Validate VAT code (Nr. de Inregistrare TVA) | ✔️ | |
| Montenegro | ME | ✔️ | |||
| Macedonia | MK | Vat Number | ✔️ | ||
| Mauritius | MU | ID number (Mauritian national identifier) | ✔️ | ||
| Netherlands | NL | Burgerservicenummer (BSN) - Citizen Service Number or Onderwijsnummer | Omzetbelastingnummer (BTW) | ✔️ | |
| Norway | NO | ✔️ | |||
| New Zealand | NZ | ✔️ | |||
| Peru | PE | RUC | RUC Peruvian company tax number | RUC Peruvian company tax number | ✔️ |
| Philippines | PH | ✔️ | |||
| Pakistan | PK | CNIC (Computerized National Identity Card) | ✔️ | ||
| Poland | PL | Polish National Identification Number (PESEL) | Numer Identyfikacji Podatkowej (NIP) | ✔️ | |
| Portugal | PT | Número de identificação civil - NIC | Numero de Identificacao Fiscal (NIF) | ✔️ | |
| Paraguay | PY | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | ✔️ |
| Romania | RO | Cod Numeric Personal - Personal Numerical Code (CNP) | Cod fiscal TVA | Cod fiscal | ✔️ |
| Serbia | RS | Unique Master Citizen Number JMBG | ✔️ | ||
| Russia | RU | Taxpayer Personal Identification Number (INN) | VAT Number | VAT Number | ✔️ |
| Slovakia | SK | Rodné Císlo (RČ) | Identifikačné číslo pre daň z pridanej hodnoty (IČ DPH) | ✔️ | |
| Slovenia | SI | Unique Master Citizen Number JMBG | Identifikacijska številka za DDV | ✔️ | |
| San Marino | SM | COE (Codice operatore economico, San Marino national tax number) | COE (Codice operatore economico, San Marino national tax number) | COE (Codice operatore economico) | ✔️ |
| El Salvador | SV | NIT (Número de Identificación Tributaria, El Salvador tax number) | ✔️ | ||
| Thailand | TH | Thailand citizen number | ✔️ | ||
| Turkey | TR | T.C. Kimlik No. (Turkish personal identification number) | VKN (Vergi Kimlik Numarası, Turkish tax identification number) | VKN (Vergi Kimlik Numarası) | ✔️ |
| Taiwan | TW | SSN | ❌ | ❌ | ✔️ |
| Spain | ES | DNI/NIF/NIE | NIF / CIF | NIF / CIF | ✔️ |
| Switzerland | CH | AHV (Sozialversicherungsnummer) | VAT, MWST, TVA, IVA, TPV (Mehrwertsteuernummer, the Swiss VAT number). | UID Unternehmens-Identifikationsnummer | ✔️ |
| Sweden | SE | Personnummer - Personal Identity Number | VAT-nummer or momsnummer | Orgnr (Organisationsnummer, Swedish company number) | ✔️ |
| United States | US | Social Security Number | Not Supported | EIN | ✔️ |
| Ukraine | UA | Social Number | VAT | VAT | ✔️ |
| Uruguay | UY | RUT numbers | RUT numbers | RUT numbers | ✔️ |
| Venezuela | VE | Registro de Informacion Fiscal (RIF) | Registro de Informacion Fiscal (RIF) | Registro de Informacion Fiscal (RIF) | ✔️ |
| South Africa | ZA | Social Number | VAT Code | VAT Code | ✔️ |
<a href="https://buymeacoffee.com/egoushka" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
Contributing
CONTRIBUTING.md has the rules this project runs on — every one of them exists because a validator here was wrong for years without anyone noticing. The short version: cite a published source for any rule you change, compute your own test numbers rather than copying them, and never write a test that asserts behaviour you believe is wrong.
docs/adding-a-country.md walks through adding or fixing a country.
KNOWN-ISSUES.md is the backlog: weaknesses found and deliberately left alone, each with the reason. Most are one validator and its test file, which makes them the natural place to start.
Security reports go through SECURITY.md. Conduct: Contributor Covenant.
License
Apache License, Version 2.0 — see LICENSE.
Copyright 2020 Anghel Valentin (original work) Copyright 2026 Yehor Hrabovskyi (changes)
Special thanks
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Attest (>= 1.0.0)
- System.ComponentModel.Annotations (>= 4.7.0)
-
net8.0
- Attest (>= 1.0.0)
- System.ComponentModel.Annotations (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.