All Projects → center-key → clabe-validator

center-key / clabe-validator

Licence: MIT license
🇲🇽 Analyze or create a CLABE number for a Mexican bank account (written in functional TypeScript)

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to clabe-validator

Sdk python
Python SDK for bunq API
Stars: ✭ 77 (+40%)
Mutual labels:  bank, financial
Bank interview
🏦 银行笔试面试经验分享及资料分享(help you pass the bank interview, and get a amazing bank offer!)
Stars: ✭ 3,308 (+5914.55%)
Mutual labels:  bank
Banking System
A banking System Created Using Django Python Web Framework
Stars: ✭ 105 (+90.91%)
Mutual labels:  bank
Logos Per Banks
LogoS is a design project about logos. In clean vector and organized as libraries to use. This one includes logos of Banks and Payment Gateways of Iran
Stars: ✭ 143 (+160%)
Mutual labels:  bank
Python N26
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/
Stars: ✭ 116 (+110.91%)
Mutual labels:  bank
Bancosbrasileiros
Lista de bancos brasileiros | Brazilian banks list
Stars: ✭ 178 (+223.64%)
Mutual labels:  bank
Timeoverflow
🏦 ⌛ A time banking system
Stars: ✭ 100 (+81.82%)
Mutual labels:  bank
latinum
Latinum is a framework for resource and currency calculations.
Stars: ✭ 109 (+98.18%)
Mutual labels:  bank
Boleto Api
API for register and generate "Boletos"
Stars: ✭ 222 (+303.64%)
Mutual labels:  bank
Go Payment
Payment Connector for Midtrans and Xendit. Sample site that is using this payment proxy is https://imrenagi.com/donate
Stars: ✭ 136 (+147.27%)
Mutual labels:  bank
Php Banks Db
PHP library for getting bank info (name, brand color etc) by first digits of card's number
Stars: ✭ 133 (+141.82%)
Mutual labels:  bank
Swiftcodes
Swift Codes or BIC Codes for all the Banks in the world. Cached to json.
Stars: ✭ 127 (+130.91%)
Mutual labels:  bank
Parbad
A free, open-source, integrated and extensible library which connects your web applications to online payment gateways. Gateways can be added or developed by you.
Stars: ✭ 194 (+252.73%)
Mutual labels:  bank
N26
API and CLI to get information of your N26 account
Stars: ✭ 107 (+94.55%)
Mutual labels:  bank
bank.logo
bank.logo
Stars: ✭ 26 (-52.73%)
Mutual labels:  bank
Laravel Bank Statements
Laravel package to collect your bank statements history. Currently support for parsing statements history from BCA, Mandiri, BNI, and MUAMALAT e-banking websites.
Stars: ✭ 105 (+90.91%)
Mutual labels:  bank
N26
💳 Un-official node.js module for interact with your N26 (previously Number26) account
Stars: ✭ 128 (+132.73%)
Mutual labels:  bank
Tqvaultae
Extra bank space for Titan Quest Anniversary Edition
Stars: ✭ 159 (+189.09%)
Mutual labels:  bank
gocnab
CNAB (Un)Marshaler
Stars: ✭ 20 (-63.64%)
Mutual labels:  bank
bank2ynab
Easily convert and import your bank's statements into YNAB. This project consolidates other conversion efforts into one universal tool.
Stars: ✭ 197 (+258.18%)
Mutual labels:  bank

CLABE Validator

logo

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

License:MIT npm 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

Web 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.js server

Install package for node:

$ npm install clabe-validator

Import package:

import { clabe } from 'clabe-validator';

Or for older CommonJS/UMD environments:

const { clabe } = require('clabe-validator');  //deprecated -- use ES modules instead

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,
   formatOk: true,
   error:    null,
   message:  'Valid',
   clabe:    '002010077777777771',
   tag:      'BANAMEX',
   bank:     'Banco Nacional de México',
   city:     'Aguascalientes MX-AGU',
   multiple: false,
   total:    1,
   account:  '07777777777',
   code:     { bank: '002', city: '010' },
   checksum: 1,
}

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 unknown).

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) TypeScript Declarations

See the TypeScript declarations at the top of the clabe.ts file.

The clabe.validate(clabeNum: string) function returns a ClabeCheck object:

type ClabeCheck = {
   ok:       boolean,        //todo está bien
   formatOk: boolean,        //valid length and checksum
   error:    string | null,  //failure code, example: 'invalid-city'
   message:  string,         //displayable status information
   clabe:    string | null,  //full 18-digit number
   tag:      string | null,  //bank short name, example: 'BANAMEX'
   bank:     string | null,  //bank long name, example: 'Banco Nacional'
   city:     string | null,  //branch or plaza name
   multiple: boolean,        //more than one city share the same code
   total:    number,         //number of cities
   account:  string,         //11-digit zero-padded bank account number
   code:     { bank: string, city: string },  //3-digit codes
   checksum: number | null,  //control digit (0 to 9)
   };

Example TypeScript usage with explicit types:

import { clabe, ClabeCheck } from 'clabe-validator';

const clabeNum:   string =     '002010077777777771';
const clabeCheck: ClabeCheck = clabe.validate(clabeNum);  //{ ok: true, error: null, ... }
const bankCode:   string =     clabeCheck.code.bank;      //'002'

F) Contributor Notes

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.

G) Genesis

The origin of this project goes back to when I needed to send money to Guanajuato, Mexico to pay nurses who were providing medical care of a relative.  I was initially unable to transfer funds because the money transfer service reported that the CLABE number I supplied was invalid.  Through a little sleuthing and a lot of luck, I discovered that a financial services company had accidentally omitted the very last modulo operation in their CLABE checksum calculation.  The result was that valid Mexican bank account numbers with certain combinations of digits were erroneously rejected.

This project was created to fix the checksum bug.  It is an open source community project and is not supported by any company.



Feel free to submit questions at:
github.com/center-key/clabe-validator/issues

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].