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 |
---|---|---|---|
- 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
You can find a demo here
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"
}
npm install
to get node dependenciesnpm run build
to build the application
npm run test
to start Jest tests.npm run test:ci
to run with coverage:- HTML and coverage reports are generated under the
dist/test-results/html
anddist/test-results/lcov-report
folders.
npm run lint
. Will check your code based on .eslintrc.json
config file
- 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