codeclassify
v1.0.1
Published
Offline, zero-dependency checksum & format validators: IBAN, GTIN/EAN/UPC, Luhn, ISIN, CUSIP, SEDOL, LEI, VIN, ISO 6346 container, ABA routing number, BIC. No network calls.
Maintainers
Readme
codeclassify
Offline checksum & format validators for the identifiers you meet in real data: IBAN, GTIN/EAN/UPC, Luhn (cards & IMEI), ISIN, CUSIP, SEDOL, LEI, VIN, ISO 6346 shipping containers, ABA routing numbers and BIC/SWIFT codes.
- Zero dependencies. Pure JavaScript, CommonJS, works on Node.js >= 14.
- 100% offline. No network calls, ever. Validate a million rows on a plane.
- Deterministic. Real check-digit maths (GS1 Mod-10, Luhn, ISO 7064 MOD 97-10, ISO 6346, ISO 13616...), not regex guesses.
- Honest. This package confirms structure and checksum only — it does not confirm that a code is actually assigned in any registry. For that, see Need more? below.
Battle-tested: these are the same algorithms running the free online validators at code-classify.com.
Install
npm install codeclassifyNote: if the name
codeclassifyis unavailable on npm, this package is published as@codeclassify/validatorsinstead —npm install @codeclassify/validatorsand change therequireaccordingly.
Usage
const cc = require('codeclassify');
cc.validateIBAN('DE89 3704 0044 0532 0130 00');
// { valid: true }
cc.validateIBAN('DE89370400440532013001');
// { valid: false, reason: 'MOD-97 checksum failed (ISO 13616).' }
cc.validateGTIN('4006381333931'); // { valid: true } (EAN-13)
cc.validateISIN('US0378331005'); // { valid: true } (Apple)
cc.validateVIN('1HGCM82633A004352');// { valid: true }Every validator takes a string (spaces and hyphens are stripped, case is ignored) and returns:
{ valid: boolean, reason?: string } // reason present only when valid === falseValidators
| Function | Identifier | Standard / algorithm | Example (valid) |
|---|---|---|---|
| validateIBAN(s) | IBAN | ISO 13616, MOD-97 checksum | DE89370400440532013000 |
| validateGTIN(s) | GTIN-8 / UPC-A / EAN-13 / GTIN-14 | GS1 Mod-10 check digit | 4006381333931 |
| validateLuhn(s) | Card numbers, IMEI, any Luhn-checked number | Luhn (mod 10) | 4111111111111111 |
| validateISIN(s) | ISIN (securities) | ISO 6166, Luhn over expanded digits | US0378331005 |
| validateCUSIP(s) | CUSIP (US/CA securities) | Modified double-add-double | 037833100 |
| validateSEDOL(s) | SEDOL (UK securities) | Weighted mod-10 | B0YBKJ7 |
| validateLEI(s) | LEI (legal entities) | ISO 17442, MOD 97-10 | 5493001KJTIIGC8Y1R12 |
| validateVIN(s) | VIN (vehicles) | ISO 3779, position-9 check digit | 1HGCM82633A004352 |
| validateContainer(s) | Shipping container | ISO 6346 check digit | CSQU3054383 |
| validateABA(s) | ABA routing number (US banks) | 3-7-1 weighted checksum | 021000021 |
| validateBIC(s) | BIC / SWIFT code | ISO 9362 structure only (BIC has no check digit) | DEUTDEFF |
Testing
npm testRuns a plain-Node test suite (no framework) with real-world codes for every validator.
Need more?
A passing checksum tells you a code is well-formed — not who it belongs to, or whether it is safe to do business with. When you need the next step, the CodeClassify API picks up where this package stops:
- Bank name from IBAN — resolve the issuing bank for IBANs from 17 countries.
- Sanctions screening — check names against the OFAC, EU, UK and UN consolidated lists.
- KYB enrichment — LEI registry lookups and legal-entity data.
- Batch validation — up to 100 identifiers per API call, or full-CSV bulk reports on the site.
250 free API calls per month, no credit card. Get a key at code-classify.com/api.
You can also use the free browser tools (IBAN checker, "What is this code?", check-digit fixer and 13 more) at code-classify.com.
License
MIT © CodeClassify
