necesito-un-trastero / id-doc-validator

A validator for different types of personal ID for multiple countries.
MIT License
7 stars 1 forks source link

id-doc-validator

A validator for different types of personal, entity and VAT IDs for multiple countries.

Supported Countries

Austria (AT) - Passport - VAT (Value Added Tax ID)
Belgium (BE) - Passport - VAT (Value Added Tax ID)
Brazil (BR) - Passport - VAT (Value Added Tax ID)
Bulgaria (BG) - Passport - VAT (Value Added Tax ID)
Canada (CA) - Passport
Colombia (CO) - VAT (Value Added Tax ID)
Czech Republic (CZ) - Passport - VAT (Value Added Tax ID)
Croatia (HR) - Passport - VAT (Value Added Tax ID)
Denmark (DK) - Passport - VAT (Value Added Tax ID)
Estonia (EE) - Passport - VAT (Value Added Tax ID)
Finland (FI) - Passport - VAT (Value Added Tax ID)
France (FR) - CNI (Carte Nationale d'Identité) - Passport - VAT (Value Added Tax ID)
Germany (DE) - GIC (German Identity Card) - Passport - VAT (Value Added Tax ID)
Greece (GR) - Passport - VAT (Value Added Tax ID) (country code: EL)
Hungary (HU) - Passport - VAT (Value Added Tax ID)
Ireland (IE) - Passport - VAT (Value Added Tax ID)
Italy (IT) - CF (Codice Fiscale) - Passport - VAT (Value Added Tax ID)
Lithuania (LT) - Passport - VAT (Value Added Tax ID)
Latvia (LV) - Passport - VAT (Value Added Tax ID)
Luxembourg (LU) - Passport - VAT (Value Added Tax ID)
Malta (MT) - Passport - VAT (Value Added Tax ID)
Mexico (MX) - Passport - VAT (Value Added Tax ID)
Netherlands (NL) - Passport - VAT (Value Added Tax ID)
Poland (PL) - Passport - VAT (Value Added Tax ID)
Portugal (PT) - CC (Cartão de Cidadão) - NIF (Número de Identificação Fiscal) - Passport - VAT (Value Added Tax ID)
Republic of Cyprus (CY) - Passport - VAT (Value Added Tax ID)
Romania (RO) - Passport - VAT (Value Added Tax ID)
Spain (ES) - DNI/NIF (Documento Nacional de Identidad / Número de Identificación Fiscal) - NIE (Número de Identificación de Extranjero) - Passport - VAT (Value Added Tax ID)
Slovakia (SK) - Passport - VAT (Value Added Tax ID)
Slovenia (SL) - Passport - VAT (Value Added Tax ID) (country code: SI)
Sweden (SE) - Passport - VAT (Value Added Tax ID)
United Kingdom (GB) - Passport - VAT (Value Added Tax ID)
United States (US) - Passport

Installation

To use the id-doc-validator library in your project, you can install it via npm or yarn:

npm install id-doc-validator
# OR
yarn add id-doc-validator

How to Use

isValidIdDoc

To validate personal identification documents, use the isValidIdDoc function. It takes three parameters:

isValidVat

To validate any VAT number from the list of Supported Countries, use the isValidVat function. It takes one parameter:

isValidViesVat

To validate a VAT number for an EU member state, use the isValidViesVat function. This function uses the API provided by the European Commission to validate the VAT number. It takes two parameters:

It returns an object with the following properties:

Please note that the VIES API is very limited in the number of requests it can handle. Please use moderately and expect the service to be unavailable at times.

supportedIdDocsByCountry

To get a list of supported identification documents for a country, use the supportedIdDocsByCountry function. It takes one parameter:

It returns an array of strings with the supported identification documents for the country.

supportedCountriesIdDoc

To get a list of supported countries for identification documents (not VAT), use the supportedCountriesIdDoc function. It takes no parameters.

It returns an array of strings with the supported countries.

supportedCountriesVat

To get a list of supported countries for VAT validation, use the supportedCountriesVat function. It takes no parameters.

It returns an array of strings with the supported VAT country codes for VAT validation.

Resources