JavaScript HTML Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE.txt
README.md
clabe.html
clabe.js
clabe.min.js
gulpfile.js
package.json
spec.js
task-runner.sh.command

README.md

CLABE Validator

logo

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

License: MIT npm Known Vulnerabilities Build Status

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

A) Online form

Try it out:
centerkey.com/clabe

B) Include

In a web page:

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

From the jsdelivr.com CDN:

<script src=https://cdn.jsdelivr.net/npm/clabe-validator@1.0/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

var clabeNum = '002010077777777771';
var clabeCheck = clabe.validate(clabeNum);
console.log(clabeCheck.error ? '¡Muy mal!' : '¡Que bueno!');

2. Example JSON result for a valid CLABE number

{
   error: false,
   bank:  'Banco Nacional de México',
   city:  'Aguascalientes'
}

3. Example JSON result for an invalid CLABE number

{
   error:   true,
   message: 'Invalid city code'
}

4. Possible error messages

Error message
Must be exactly 18 digits long
Must be only numeric digits (no letters)
Invalid checksum
Invalid bank code
Invalid city 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.

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

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.