company-id-validator
v1.22.2
Published
A Javascript library to validate company identifiers algorithms for many countries
Maintainers
Readme
Company id validator
This Javascript library helps you to validate and get detailed information for a company/business identifier. It's inspired from this awesome ptdnum python library
| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| |
|
|
|
Why ?
- Each country has its own company/business identifier and their name and validation algorithms are very specific from one country to another.
- It is very difficult to gather information about local company identifiers: For example, do you know the name of the chinese company identifier ? it's format ? How to validate it ?
- That's the purpose of this library
Demo
You can find a demo here
How to use it
npm install company-id-validator --save- You can now validate a company identifier based on its country code:
import { CompanyId } from 'company-id-validator';
CompanyId.validate('FR', '802070748'); // Should return true- You can also get detailed information:
import { CompanyId } from 'company-id-validator';
const info = CompanyId.info('FR', '802070748');
console.log(info);{
"valid": true,
"query": "802070748",
"sanitizedQuery": "802070748",
"countryCode": "FR",
"name": "SIREN",
"fullName": "Système d'Identification du Répertoire des Entreprises",
"type": "LOCAL_COMPANY_ID",
"description": "The SIREN (Système d'Identification du Répertoire des Entreprises) is a 9\ndigit number used to identify French companies. The Luhn checksum is used\nto validate the numbers.",
"trustedSourceUrl": "https://fr.wikipedia.org/wiki/Syst%C3%A8me_d%27identification_du_r%C3%A9pertoire_des_entreprises",
"pattern": "^[0-9]{3}[ \\.\\-]?[0-9]{3}[ \\.\\-]?[0-9]{3}$",
"parentLevel": true,
"countryName": "France",
"id": "802070748",
"vatNumber": "FR89802070748"
}Getting started
npm installto get node dependenciesnpm run buildto build the application
Tests
Unit tests
npm run testto start Jest tests.npm run test:cito run with coverage:- HTML and coverage reports are generated under the
dist/test-results/htmlanddist/test-results/lcov-reportfolders.
Code quality
npm run lint. Will check your code based on .eslintrc.json config file
Roadmap
- For now 15 countries are supported: AD, AL, AT, BE, CH, CN, DE, ES, FR, GB, IT, NI, NO, PL, SC, SE, JP
- Need to add many more countries based on the ptdnum python library
