Skip to content

A validator for different types of personal ID for multiple countries.

License

Notifications You must be signed in to change notification settings

ChewyToast/id-doc-validator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

id-doc-validator

A validator for different types of personal ID for multiple countries.

Supported Countries

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)
Italy (IT)
  • CF (Codice Fiscale)
  • Passport
  • VAT (Value Added Tax ID)
Spain (ES)
  • DNI (Documento Nacional de Identidad)
  • NIF (Número de Identificación Fiscal)
  • NIE (Número de Identificación de Extranjero)
  • Passport
  • VAT (Value Added Tax ID)

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

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

  • idDoc (string): The identification document number to validate.
  • country (string): The alpha-2 country code following ISO 3166-1 (e.g., "ES" for Spain, "FR" for France).
  • idDocType (string, optional): The type of identification document to validate. For a list of supported identification document types, please refer to the expanded view of the Supported Countries. If this parameter is not passed, the function will check if the passed id doc is valid for any of the supported id docs for the country.

Example Usage:

// Import the id-doc-validator library
const { isValidIdDoc } = require("id-doc-validator");

const idDoc = "your_identification_number";
const country = "ES"; // Country code
const idDocType = "DNI"; // Type of identification document

const isValid = isValidIdDoc(idDoc, country, idDocType);

if (isValid) {
  console.log("The identification document is valid.");
} else {
  console.log("The identification document is not valid.");
}

About

A validator for different types of personal ID for multiple countries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%