npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clabe-validator-updated

v1.3.9

Published

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

Downloads

10

Readme

CLABE Validator

!! This is a fork from https://github.com/center-key/clabe-validator !!

!! Just to make urgent changes for a production system. !!

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) Setup

Browser

Include in a web page:

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

or from the jsdelivr.com CDN:

<script src=https://cdn.jsdelivr.net/npm/[email protected]/dist/clabe.min.js></script>

node

Install package:

$ npm install clabe-validator

Import package:

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: ' + clabeCheck.bank);

2. Example JSON result for a valid CLABE number

{
   ok:       true,
   error:    null,
   formatOk: true,
   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,
   formatOk: true,
   error:    'invalid-city',
   message:  'Invalid city code: 000'
}

The formatOk field indicates if the CLABE's length and checksum are both valid (even if the bank code or city code are invalid).

4. Possible errors

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

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 run the commands npm install and npm test on your local clone.  Make your edits and rerun the tests.  Pull requests welcome (no need to update the version in package.json or any files in the dist folder as they are all updated as part of the release process).

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