JSPM

  • Created
  • Published
  • Downloads 8921
  • Score
    100M100P100Q140347F
  • License MIT

JavaScript library to analyze or create a CLABE number for a Mexican bank account

Package Exports

  • clabe-validator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clabe-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CLABE Validator

logo

JavaScript library to analyze or create a CLABE number for a Mexican bank account

License:MIT npm Dependencies Vulnerabilities Hits Build

CLABE (Clave Bancaria Estandarizada — Spanish for "standardized banking code") is a banking standard from the Mexican Bank Association (Asociación de Bancos de México — ABM) for uniform numbering of bank accounts.  CLABE numbers are 18 digits long.  See: https://en.wikipedia.org/wiki/CLABE

A) Online form

Try it out:
https://centerkey.com/clabe

B) Include

In a web page:

<script src=clabe.min.js></script>

From the jsdelivr.com CDN:

<script src=https://cdn.jsdelivr.net/npm/clabe-validator@1.3/dist/clabe.min.js></script>

In a Node.js project:

$ npm install clabe-validator
const clabe = require('clabe-validator');

C) Validator usage

Pass the CLABE number as an 18-character string into clabe.validate(clabeNum).

1. Example JavaScript code

const clabeNum = '002010077777777771';
const clabeCheck = clabe.validate(clabeNum);
console.log(clabeCheck.ok ? '¡Que bueno!' : '¡Muy mal!');
console.log('Your bank is ' + clabeCheck.bank);

2. Example JSON result for a valid CLABE number

{
   ok:      true,
   error:   null,
   tag:     'BANAMEX',
   bank:    'Banco Nacional de México, S.A.',
   city:    'Aguascalientes',
   account: '07777777777'
}

3. Example JSON result for an invalid CLABE number

{
   ok:      false,
   error:   'invalid-city'
   message: 'Invalid city code: 000'
}

4. Possible errors

Error code Error message
invalid-length Must be exactly 18 digits long
invalid-characters Must be only numeric digits (no letters)
invalid-checksum Invalid checksum, last digit should be: [DIGIT]
invalid-bank Invalid bank code: [CODE]
invalid-city Invalid city code: [CODE]

D) Calculator usage

Pass the bank code, city code, and account number into clabe.calculate(bankCode, cityCode, accountNumber) and get the 18-character CLABE number back.

const clabeNum = clabe.calculate(2, 10, 7777777777);
console.log(clabeNum === '002010077777777771')  //true;

E) Notes

  1. Feel free to submit questions at: github.com/center-key/clabe-validator/issues
  2. To be a contributor, fork the project and execute the task-runner.sh.command script. Make your edits and rerun the script to ensure all the test cases pass. Pull requests welcome.

CLABE Validator code is open source under the MIT License, and the documentation is published under the CC BY-SA 4.0 license.