center-key / clabe-validator Goto Github PK
View Code? Open in Web Editor NEW🇲🇽 Analyze or create a CLABE number for a Mexican bank account (with TypeScript declarations)
Home Page: https://clabe-validator.js.org
License: MIT License
🇲🇽 Analyze or create a CLABE number for a Mexican bank account (with TypeScript declarations)
Home Page: https://clabe-validator.js.org
License: MIT License
For multiline arrays and objects, the consistency of including a comma for the last item makes the code easier to edit and helps reduce merge diffs.
See:
https://jshint.com/docs/options/#trailingcomma
For example, change:
const dataSet = [
{ input: '002', expected: 'BANAMEX' },
{ input: '640', expected: 'CB JPMORGAN' },
{ input: '652', expected: 'CREDICAPITAL' } //no comma
];
to:
const dataSet = [
{ input: '002', expected: 'BANAMEX' },
{ input: '640', expected: 'CB JPMORGAN' },
{ input: '652', expected: 'CREDICAPITAL' }, //with comma
];
Configure the project to enforce the JSHint rule that prohibits var
statements.
See "jshintConfig"
in package.json:
https://github.com/center-key/clabe-validator/blob/master/package.json#L24
JSHint documentation:
https://jshint.com/docs/options/#varstmt
Apparently there's still a need to support really old js where parseInt()
requires the radix
parameter to work correctly. See: Issue #14
The cleanest fix is probably just to switch to using Number()
.
This change requires swapping out all occurrences of parseInt(..., 10)
with Number(...)
.
For example, change:
const checksum = parseInt(clabeNum.substring(17, 18), 10);
to:
const checksum = Number(clabeNum.substring(17, 18));
Run $ npm test
to verify all the test cases still pass.
Hello,
Just wanted to report an error I noticed while trying to validate an NVIO CLABE (e.g. 710969000000000004
). I get the error Invalid city code: 969
when I'm sure the clabe is 100% correct and working because it's being used for transfer.
Thanks!
Hello. @dpilafian
Thank you for the awesome package!
Version 1.5.2 is not compatible with 1.5.1. You published a breaking change as SemVer MINOR.
The main clabe.js
1.5.1 used to have this line:
if (typeof module === "object") module.exports = clabe;
The 1.5.2 does not have it any more. It broke our production builds.
See this line: 6762632#diff-ecf689c52ec37d55479746c939f7e7e13882c8df8848ce65741f8a1e1ad7ae0bL1085
Could you please add back the CommonJS compatibility to the 1.x line?
Thank you
See list of cites at:
https://www.bancanetempresarial.banamex.com.mx/spanishdir/bankhelp/win_archivoscargosdomicilia.htm
Tijuana has an entry for 27 and 28.
Add new bank codes from:
bridge21@3af825d
846: 'Sistema de Transferencias y Pagos STP',
Hi! I can send a PR if needed but wanted to discuss this first. We've been working with STP, and they have a secondary Bank Code, which I believe they only use for tests. The problem is that they do have "valid clabes" but the CLABE Validator says it's not valid because it starts with 846.
Thoughts? Thanks!
Upgrade to more modern ES6 function definitions. The newer notation is more compact and looks better.
See MDN web docs:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions
Add new city/region codes from:
bridge21@e0e0702
bridge21@1f8c7aa
bridge21@5716f6d
Bank codes:
https://es.wikipedia.org/wiki/CLABE#C.C3.B3digo_de_banco
clabe.js
bank: {
2: 'Banco Nacional de México',
12: 'BBVA Bancomer',
14: 'Banco Santander',
...
902: 'SD. INDEVAL'
},
A valid key is reported as invalid
012660015490725198 is a valid key from BBVA and I expect it to be marked as valid
Also, it is marked as valid using this tool --> https://bank.codes/mexico-clabe-checker/ (but I love center-key/clabe-validator so I wont use the other)
012660015490725198 is marked as invalid --> Invalid city
Update to gulp 4.0 to avoid:
High | Regular Expression Denial of Service |
---|---|
Package | minimatch |
Dependency of | gulp [dev] |
Path | gulp > vinyl-fs > glob-stream > minimatch |
More info | https://nodesecurity.io/advisories/118 |
City codes:
https://es.wikipedia.org/wiki/CLABE#C.C3.B3digo_de_plaza
clabe.js
cities: [
[ 10, 'Aguascalientes'],
[ 12, 'Calvillo'],
[ 14, 'Jesús María'],
...
[960, 'Calera de V. Rosales']
]
The function assert.deepEqual()
has been deprecated:
https://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message
Replace with:
assert.deepStrictEqual()
And change:
const assert = require('assert').strict;
to:
const assert = require('assert');
Time for v12:
https://nodejs.org/en/about/releases/
See:
.travis.yml
When I enter a number, nothing happens. Unless I'm using this site wrong :)
Javascript console says:
jquery.min.js:2 Uncaught ReferenceError: clabe is not defined
at S.fn.init.setupCalculator ((index):200)
at f (dna.min.js:3)
at f (dna.min.js:3)
at findFn (dna.min.js:3)
at Object.apply (dna.min.js:3)
at run (dna.min.js:3)
at HTMLDivElement. (lib-x.min.js:3)
at Function.each (jquery.min.js:2)
at S.fn.init.each (jquery.min.js:2)
at S.fn.init.forEach (lib-x.min.js:3)
For multiline arrays and objects, the consistency of including a comma for the last item makes the code easier to edit and helps reduce merge diffs.
See:
https://jshint.com/docs/options/#trailingcomma
For example, change:
const dataSet = [
{ input: '002', expected: 'BANAMEX' },
{ input: '640', expected: 'CB JPMORGAN' },
{ input: '652', expected: 'CREDICAPITAL' } //no comma
];
to:
const dataSet = [
{ input: '002', expected: 'BANAMEX' },
{ input: '640', expected: 'CB JPMORGAN' },
{ input: '652', expected: 'CREDICAPITAL' }, //with comma
];
If you add the hacktoberfest
topic to the repository, more contributors will address the issues available.
Hi ✋
I'm trying to use this in my reactjs project to validate de CLABE in the front-end, but when I try tu use it throws the next error:
Unhandled Rejection (TypeError): Cannot read property 'validate' of undefined
I'm trying to use it exactly as the README say.
import { clabe } from "clabe-validator";
----
const clabeNum = "002010077777777771";
const clabeCheck = clabe.validate(clabeNum);
console.log(clabeCheck);
Apparently there's still a need to support really old js where parseInt()
requires the radix
parameter to work correctly. See: Issue #14
The cleanest fix is probably just to switch to using Number()
.
Hi! This clabe 646521162218542788 is not working because the city is not in the list.
It could be a good idea to allow validation of bank only.
Listado de instituciones:
https://www.banxico.org.mx/cep-scl/listaInstituciones.do
Consider adding the following two missing bank codes:
Clave de la institución | code | Nombre de la institución |
---|---|---|
90688 | 688 | CREDICLUB |
90703 | 703 | TESORED |
List copied from Banco de México website:
const banxicoList = [
['40138', 'ABC CAPITAL'],
['40133', 'ACTINVER'],
['40062', 'AFIRME'],
['90661', 'ALTERNATIVOS'],
['90706', 'ARCUS'],
['90659', 'ASP INTEGRA OPC'],
['40128', 'AUTOFIN'],
['40127', 'AZTECA'],
['37166', 'BaBien'],
['40030', 'BAJIO'],
['40002', 'BANAMEX'],
['40154', 'BANCO COVALTO'],
['37006', 'BANCOMEXT'],
['40137', 'BANCOPPEL'],
['40160', 'BANCO S3'],
['40152', 'BANCREA'],
['37019', 'BANJERCITO'],
['40147', 'BANKAOOL'],
['40106', 'BANK OF AMERICA'],
['40159', 'BANK OF CHINA'],
['37009', 'BANOBRAS'],
['40072', 'BANORTE'],
['40058', 'BANREGIO'],
['40060', 'BANSI'],
['02001', 'BANXICO'],
['40129', 'BARCLAYS'],
['40145', 'BBASE'],
['40012', 'BBVA MEXICO'],
['40112', 'BMONEX'],
['90677', 'CAJA POP MEXICA'],
['90683', 'CAJA TELEFONIST'],
['90630', 'CB INTERCAM'],
['40143', 'CIBANCO'],
['90631', 'CI BOLSA'],
['90901', 'CLS'],
['90903', 'CoDi Valida'],
['40130', 'COMPARTAMOS'],
['40140', 'CONSUBANCO'],
['90652', 'CREDICAPITAL'],
['90688', 'CREDICLUB'],
['90680', 'CRISTOBAL COLON'],
['40151', 'DONDE'],
['90616', 'FINAMEX'],
['90634', 'FINCOMUN'],
['90689', 'FOMPED'],
['90685', 'FONDO (FIRA)'],
['90601', 'GBM'],
['37168', 'HIPOTECARIA FED'],
['40021', 'HSBC'],
['40155', 'ICBC'],
['40036', 'INBURSA'],
['90902', 'INDEVAL'],
['40150', 'INMOBILIARIO'],
['40136', 'INTERCAM BANCO'],
['90686', 'INVERCAP'],
['40059', 'INVEX'],
['40110', 'JP MORGAN'],
['90653', 'KUSPIT'],
['90670', 'LIBERTAD'],
['90602', 'MASARI'],
['40042', 'MIFEL'],
['40158', 'MIZUHO BANK'],
['90600', 'MONEXCB'],
['40108', 'MUFG'],
['40132', 'MULTIVA BANCO'],
['90613', 'MULTIVA CBOLSA'],
['37135', 'NAFIN'],
['90638', 'NU MEXICO'],
['90710', 'NVIO'],
['90684', 'OPM'],
['40148', 'PAGATODO'],
['90620', 'PROFUTURO'],
['40156', 'SABADELL'],
['40014', 'SANTANDER'],
['40044', 'SCOTIABANK'],
['40157', 'SHINHAN'],
['90646', 'STP'],
['90648', 'TACTIV CB'],
['90703', 'TESORED'],
['90656', 'UNAGRA'],
['90617', 'VALMEX'],
['90605', 'VALUE'],
['90608', 'VECTOR'],
['40113', 'VE POR MAS'],
['40141', 'VOLKSWAGEN'],
];
module.exports
Configure the project to enforce the JSHint rule that prohibits non-breaking whitespace characters.
See "jshintConfig"
in package.json:
https://github.com/center-key/clabe-validator/blob/master/package.json#L24
JSHint documentation:
https://jshint.com/docs/options/#nonbsp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.