CountryValidator
C# Validations for Social Security Numbers, VAT Codes and tax identification numbers
Install / Use
/learn @anghelvalentin/CountryValidatorREADME
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
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) | :heavy_check_mark: | | United Arab Emirates | AE | | :x: | :x: | :x: | | Albania | AL | Identity Number - Numri i Identitetit (NID) | NIPT (Numri i Identifikimit për Personin e Tatueshëm, Albanian VAT number). | NIPT | :heavy_check_mark: | | Armenia | AM | TIN Number | TIN Number | TIN Number | :heavy_check_mark: | | Argentina | AR | DNI number | VAT/IVA/CUIT | CUIT | :heavy_check_mark: | | Austria | AT | Versicherungsnummer (VNR, SVNR, VSNR) | UID (Umsatzsteuer-Identifikationsnummer) | | :heavy_check_mark: | | Australia | AU | TFN | ABN | ABN/ACN/TFN | :heavy_check_mark: | | Azerbaijan | AZ | PIN - Personal Identification Number | VÖEN/TIN Number | VÖEN/TIN Number | :heavy_check_mark: | | Bosnia | BA | Unique Master Citizen Number JMBG | | :x: | :heavy_check_mark: | | Belgium | BE | Rijksregisternummer | BTW, TVA, NWSt, ondernemingsnummer (Belgian enterprise number). | | :heavy_check_mark: | | Bulgaria | BG | Edinen grazhdanski nomer (EGN) | Идентификационен номер по ДДС | | :heavy_check_mark: | | Bahrain | BH | Social security number | :x: | :x: | :heavy_check_mark: | | Bolivia | BO | CI Number | Número de Identificación Tributaria | Número de Identificación Tributaria | :heavy_check_mark: | | Brazil | BR | CPF | Brazil Cadastro Nacional da Pessoa Juridica (CNPJ) | Brazil Cadastro Nacional da Pessoa Juridica (CNPJ) | :heavy_check_mark: | | Belarus | BY | Payer's account number (UNP) | Payer's account number (UNP) | Payer's account number (UNP) | :heavy_check_mark: | | Canada | CA | SIN Number | Business Number | Business Number | :heavy_check_mark: | | Chile | CL | National Tax Number (RUN/RUT) | National Tax Number (RUN/RUT) | National Tax Number (RUN/RUT) | :heavy_check_mark: | | China | CN | Social Number (15 digits and 18 digits) | :x: | Business Number | :heavy_check_mark: | | Colombia | CO | NIT (Número De Identificación Tributaria, Colombian identity code) | VAT | RUT (Registro Unico Tributario) | :heavy_check_mark: | | Costa Rica | CR | CPF (Cédula de Persona Física,physical person ID number)/CR(Cédula de Residencia) | CPJ | CPJ | :heavy_check_mark: | | Cuba | CU | NI (Número de identidad) | :x: | :x: | :heavy_check_mark: | | Croatia | HR | OIB (Osobni identifikacijski broj, Croatian identification number) | OIB (Osobni identifikacijski broj, Croatian identification number) | OIB (Osobni identifikacijski broj) | :heavy_check_mark: | | Cyprus | CY | Identity Number | ΦΠΑ | | :heavy_check_mark: | | Czechia | CZ | Rodné Císlo (RČ) | Danove Identifikacni Cislo (DIC/VAT) | | :heavy_check_mark: | | Denmark | DK | Det Centrale Personregister (CPR) | Momsregistreringsnummer (CVR/VAT) | | :heavy_check_mark: | | Dominican Republic | DO | Cedula | RNC (Registro Nacional del Contribuyente) | RNC (Registro Nacional del Contribuyente) | :heavy_check_mark: | | Ecuador | EC | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | Registro Unico de Contribuyentes (RUC) | :heavy_check_mark: | | Estonia | EE | Personal Id - Isikukood | Kaibemaksukohuslase (KMKR) | Registrikood (Estonian organisation registration code) | :heavy_check_mark: | | Finland | FI | Henkilötunnus (HETU)
