clabe-validator 1.7.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +23 -20
- package/dist/clabe.d.ts +7 -4
- package/dist/clabe.dev.js +906 -903
- package/dist/clabe.js +906 -903
- package/dist/clabe.min.js +2 -2
- package/dist/clabe.umd.cjs +906 -903
- package/package.json +17 -17
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
3
|
+
Copyright (c) 2017-2022 individual contributors to CLABE Validator
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ _JavaScript library to analyze or create a CLABE number for a Mexican bank accou
|
|
|
7
7
|
[](https://www.npmjs.com/package/clabe-validator)
|
|
8
8
|
[](https://snyk.io/test/github/center-key/clabe-validator)
|
|
9
9
|
[](https://www.jsdelivr.com/package/npm/clabe-validator)
|
|
10
|
-
[](https://github.com/center-key/clabe-validator/actions
|
|
10
|
+
[](https://github.com/center-key/clabe-validator/actions/workflows/run-spec-on-push.yaml)
|
|
11
11
|
|
|
12
12
|
CLABE (Clave Bancaria Estandarizada — Spanish for "standardized banking code") is a banking
|
|
13
13
|
standard from the Mexican Bank Association (Asociación de Bancos de México — ABM) for
|
|
@@ -42,15 +42,12 @@ Or for older CommonJS/UMD environments:
|
|
|
42
42
|
const { clabe } = require('clabe-validator'); //deprecated
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
**Note:** _Release v1.4.0 contains a significant number of bank and city code additions plus
|
|
46
|
-
updates to reflect financial institution mergers and name changes._
|
|
47
|
-
|
|
48
45
|
## C) Validator Usage
|
|
49
46
|
Pass the CLABE number as an 18-character string into `clabe.validate(clabeNum)`.
|
|
50
47
|
|
|
51
48
|
### 1. Example JavaScript code
|
|
52
49
|
```javascript
|
|
53
|
-
const clabeNum =
|
|
50
|
+
const clabeNum = '002010077777777771';
|
|
54
51
|
const clabeCheck = clabe.validate(clabeNum);
|
|
55
52
|
console.log(clabeCheck.ok ? '¡Que bueno!' : '¡Muy mal!');
|
|
56
53
|
console.log('Your bank: ' + clabeCheck.bank);
|
|
@@ -65,8 +62,10 @@ console.log('Your bank: ' + clabeCheck.bank);
|
|
|
65
62
|
message: 'Valid',
|
|
66
63
|
clabe: '002010077777777771',
|
|
67
64
|
tag: 'BANAMEX',
|
|
68
|
-
bank: 'Banco Nacional de México
|
|
65
|
+
bank: 'Banco Nacional de México',
|
|
69
66
|
city: 'Aguascalientes MX-AGU',
|
|
67
|
+
multiple: false,
|
|
68
|
+
total: 1,
|
|
70
69
|
account: '07777777777',
|
|
71
70
|
code: { bank: '002', city: '010' },
|
|
72
71
|
checksum: 1,
|
|
@@ -110,17 +109,19 @@ The **TypeScript Declaration File** file is [clabe.d.ts](dist/clabe.d.ts) in the
|
|
|
110
109
|
The `clabe.validate(clabeNum: string)` function returns a `ClabeCheck` object:
|
|
111
110
|
```typescript
|
|
112
111
|
type ClabeCheck = {
|
|
113
|
-
ok: boolean,
|
|
114
|
-
formatOk: boolean,
|
|
115
|
-
error: string | null,
|
|
116
|
-
message: string,
|
|
117
|
-
clabe: string | null,
|
|
118
|
-
tag: string | null,
|
|
119
|
-
bank: string | null,
|
|
120
|
-
city: string | null,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
ok: boolean, //todo está bien
|
|
113
|
+
formatOk: boolean, //valid length and checksum
|
|
114
|
+
error: string | null, //failure code, example: 'invalid-city'
|
|
115
|
+
message: string, //displayable status information
|
|
116
|
+
clabe: string | null, //full 18-digit number
|
|
117
|
+
tag: string | null, //bank short name, example: 'BANAMEX'
|
|
118
|
+
bank: string | null, //bank long name, example: 'Banco Nacional'
|
|
119
|
+
city: string | null, //branch or plaza name
|
|
120
|
+
multiple: boolean, //more than one city share the same code
|
|
121
|
+
total: number, //number of cities
|
|
122
|
+
account: string, //11-digit zero-padded bank account number
|
|
123
|
+
code: { bank: string, city: string }, //3-digit codes
|
|
124
|
+
checksum: number | null, //control digit (0 to 9)
|
|
124
125
|
};
|
|
125
126
|
```
|
|
126
127
|
|
|
@@ -128,9 +129,9 @@ Example TypeScript usage with explicit types:
|
|
|
128
129
|
```typescript
|
|
129
130
|
import { clabe, ClabeCheck } from 'clabe-validator';
|
|
130
131
|
|
|
131
|
-
const clabeNum:
|
|
132
|
+
const clabeNum: string = '002010077777777771';
|
|
132
133
|
const clabeCheck: ClabeCheck = clabe.validate(clabeNum); //{ ok: true, error: null, ... }
|
|
133
|
-
const bankCode:
|
|
134
|
+
const bankCode: string = clabeCheck.code.bank; //'002'
|
|
134
135
|
```
|
|
135
136
|
|
|
136
137
|
## F) Contributor Notes
|
|
@@ -144,10 +145,12 @@ I was initially unable to transfer funds because the money transfer service repo
|
|
|
144
145
|
number I supplied was invalid.
|
|
145
146
|
Through a little sleuthing and a lot of luck, I discovered that a financial services company had
|
|
146
147
|
accidentally omitted the very last modulo operation in their CLABE checksum calculation.
|
|
147
|
-
The result was that Mexican bank account numbers
|
|
148
|
+
The result was that Mexican bank account numbers with certain combinations of digits were
|
|
149
|
+
erroneously rejected.
|
|
148
150
|
|
|
149
151
|
This project was created to fix the checksum bug.
|
|
150
152
|
It is an open source community project and is not supported by any company.
|
|
153
|
+
|
|
151
154
|
<br>
|
|
152
155
|
|
|
153
156
|
---
|
package/dist/clabe.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! clabe-validator
|
|
1
|
+
//! clabe-validator v2.0.0 ~~ https://github.com/center-key/clabe-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
export declare type ClabeBank = {
|
|
4
4
|
tag?: string;
|
|
@@ -7,9 +7,9 @@ export declare type ClabeBank = {
|
|
|
7
7
|
export declare type ClabeBanksMap = {
|
|
8
8
|
[bankCode: number]: ClabeBank;
|
|
9
9
|
};
|
|
10
|
-
export declare type
|
|
10
|
+
export declare type ClabeCityInfo = [number, string, ClabeMxState?];
|
|
11
11
|
export declare type ClabeCitiesMap = {
|
|
12
|
-
[cityCode: number]:
|
|
12
|
+
[cityCode: number]: ClabeCityInfo[];
|
|
13
13
|
};
|
|
14
14
|
export declare type ClabeCheck = {
|
|
15
15
|
ok: boolean;
|
|
@@ -20,6 +20,8 @@ export declare type ClabeCheck = {
|
|
|
20
20
|
tag: string | null;
|
|
21
21
|
bank: string | null;
|
|
22
22
|
city: string | null;
|
|
23
|
+
multiple: boolean;
|
|
24
|
+
total: number;
|
|
23
25
|
account: string;
|
|
24
26
|
code: {
|
|
25
27
|
bank: string;
|
|
@@ -27,13 +29,14 @@ export declare type ClabeCheck = {
|
|
|
27
29
|
};
|
|
28
30
|
checksum: number | null;
|
|
29
31
|
};
|
|
32
|
+
export declare type ClabeMxState = 'MX-AGU' | 'MX-BCN' | 'MX-BCS' | 'MX-CAM' | 'MX-CHH' | 'MX-CHP' | 'MX-CMX' | 'MX-COA' | 'MX-COL' | 'MX-DUR' | 'MX-GRO' | 'MX-GUA' | 'MX-HID' | 'MX-JAL' | 'MX-MEX' | 'MX-MIC' | 'MX-MOR' | 'MX-NAY' | 'MX-NLE' | 'MX-OAX' | 'MX-PUE' | 'MX-QUE' | 'MX-ROO' | 'MX-SIN' | 'MX-SLP' | 'MX-SON' | 'MX-TAB' | 'MX-TAM' | 'MX-TLA' | 'MX-VER' | 'MX-YUC' | 'MX-ZAC';
|
|
30
33
|
declare const clabe: {
|
|
31
34
|
version: string;
|
|
32
35
|
computeChecksum(clabeNum17: string): number | null;
|
|
33
36
|
validate(clabeNum: string): ClabeCheck;
|
|
34
37
|
calculate(bankCode: number, cityCode: number, accountNumber: number): string;
|
|
35
38
|
banksMap: ClabeBanksMap;
|
|
36
|
-
cities:
|
|
39
|
+
cities: ClabeCityInfo[];
|
|
37
40
|
citiesMap: ClabeCitiesMap;
|
|
38
41
|
};
|
|
39
42
|
export { clabe };
|