Skip to content

C# Validations for Social Security Numbers, VAT Codes and tax identification numbers

Notifications You must be signed in to change notification settings

anghelvalentin/CountryValidator

Repository files navigation

Country Validator

Country Validator is a .NET library that can validate VAT codes, national identification numbers and tax identification numbers for individuals and companies

Features

  • Validate Social Security Numbers/Personal Identity Numbers
  • Validate VAT Codes
  • Validate Tax Indentification Numbers for Individuals
  • Validate Tax Identification Numbers For Companies

Install

Nuget Package CountryValidator Nuget Package CountryValidator.DataAnnotations

Install-Package CountryValidator
Install-Package CountryValidator.DataAnnotations

How to use Country Validator

Using Validator Class

CountryValidator validator = new CountryValidator();
ValidationResult validationResult = validator.ValidateNationalIdentityCode(ssn, Country.US);
if (validationResult.IsValid)
{
    Console.WriteLine("Valid");
}
else
{
    Console.WriteLine(validationResult.ErrorMessage);
}

Using Data Annotations

[HttpPost]
public IActionResult ValidateSSN([Required, SSNAttribute(Country.US)]string ssn)
{
    if (!ModelState.IsValid)
    {
        //log exception
    }
    return Ok();
}

Live Demo

Social Security Number Validation

VAT Code Validation

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 ✔️

Buy Me A Coffee

License

Copyright 2020 Anghel Valentin

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Special thanks

Python Stdnum

About

C# Validations for Social Security Numbers, VAT Codes and tax identification numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages