ibantools 3.3.0 → 4.1.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/ChangeLog +47 -0
- package/README.md +15 -4
- package/build/ibantools.d.ts +5 -3
- package/build/ibantools.js +178 -42
- package/jsnext/ibantools.js +178 -42
- package/package.json +14 -14
package/ChangeLog
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
|
+
2021-11-25 Saša Jovanić <sasa@simplify.ba>
|
|
2
|
+
* Version 4.1.0
|
|
3
|
+
* Added Belgian (BE) extra BBAN validation
|
|
4
|
+
* Added mod97/10 BBAN validation for countries that do it that way: BA, ME, MK, PT, RS and SI
|
|
5
|
+
|
|
6
|
+
2021-11-24 Saša Jovanić <sasa@simplify.ba>
|
|
7
|
+
* Added Netherlands (NL) extra BBAN validation
|
|
8
|
+
* Added extra error code when validating IBAN `WrongAccountBankBranchChecksum` that indicates when checksum for account number or bank or branch code is incorrect
|
|
9
|
+
|
|
10
|
+
2021-11-23 Saša Jovanić <sasa@simplify.ba>
|
|
11
|
+
* Version 4.0.1
|
|
12
|
+
* Fixed bug when validating Spain IBAN
|
|
13
|
+
|
|
14
|
+
2021-11-18 Saša Jovanić <sasa@simplify.ba>
|
|
15
|
+
* Updated README with new and updated badges
|
|
16
|
+
* Fixed documentation on GH pages
|
|
17
|
+
* Added dependabot dependency updates and merged some created dependency pull requests
|
|
18
|
+
* Added Node 17 to build version on GitHub actions
|
|
19
|
+
* Added GitHub CodeQL workflow
|
|
20
|
+
|
|
21
|
+
2021-11-17 Saša Jovanić <sasa@simplify.ba>
|
|
22
|
+
* Version 4.0.0
|
|
23
|
+
* Fixed Senegal (SN) regular expression
|
|
24
|
+
* Updated Burundi (BI) specification
|
|
25
|
+
* Added Spain (ES) extra BBAN validation
|
|
26
|
+
* Added Poland (PL) extra BBAN validation
|
|
27
|
+
* Added test to check for extra BBAN validation function
|
|
28
|
+
|
|
29
|
+
2021-09-30 Simen Mailund Svendsen <simen.m.s@hotmail.com>
|
|
30
|
+
* Fix invalid norwegian BBANS (failing MOD11 check) being incorrectly returned as valid
|
|
31
|
+
|
|
32
|
+
2021-07-24 Saša Jovanić <sasa@simplify.ba>
|
|
33
|
+
* Version 3.3.1
|
|
34
|
+
* Fixed issue not showing AD and BG as SEPA countries
|
|
35
|
+
* Fixed issue when incorrectly showing GL and FO as SEPA countryes
|
|
36
|
+
* Fixed incorrect documentation for `composeIBAN`
|
|
37
|
+
* Updates list of supported Node.js versions
|
|
38
|
+
* Update dev dependencies
|
|
39
|
+
|
|
40
|
+
2021-05-05 Daniel Friesen <d@danf.ca>
|
|
41
|
+
* Fixed `validateIBAN`'s handling of unsupported countries like US
|
|
42
|
+
* Added checksum validation for unsupported/unknown countries to `validateIBAN`
|
|
43
|
+
|
|
44
|
+
2021-04-03 Saša Jovanić <sasa@simplify.ba>
|
|
45
|
+
* Coverage improved to 100%
|
|
46
|
+
|
|
1
47
|
2021-04-03 Saša Jovanić <sasa@simplify.ba>
|
|
48
|
+
* Version 3.3.0
|
|
2
49
|
* Error codes for IBAN and BIC validation. Added `validateIBAN` and `validateBIC` methods that will return error codes.
|
|
3
50
|
|
|
4
51
|
2021-04-03 Saša Jovanić <sasa@simplify.ba>
|
package/README.md
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
# IBANTools
|
|
2
2
|
|
|
3
|
-
[](https://github.com/Simplify/ibantools/blob/master/LICENSE)
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/bo/ibantools)
|
|
6
6
|
[](https://badge.fury.io/js/ibantools)
|
|
7
|
+
[](https://www.npmjs.com/package/ibantools)
|
|
8
|
+

|
|
7
9
|
|
|
8
10
|
/badge.svg?branch=master)
|
|
9
11
|

|
|
10
12
|
[](https://coveralls.io/github/Simplify/ibantools?branch=master)
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+

|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
## About
|
|
14
25
|
|
|
15
26
|
IBANTools is TypeScript/JavaScript library for validation, creation and extraction of IBAN, BBAN and BIC/SWIFT numbers.
|
|
16
27
|
|
|
@@ -19,7 +30,7 @@ For more information about IBAN/BBAN see [wikipedia page](https://en.wikipedia.o
|
|
|
19
30
|
|
|
20
31
|
For more information about BIC/SWIFT see [this wikipedia page](https://en.wikipedia.org/wiki/ISO_9362).
|
|
21
32
|
|
|
22
|
-
## Installation
|
|
33
|
+
## Installation
|
|
23
34
|
|
|
24
35
|
### Node (Common JS ES5 and ES6)
|
|
25
36
|
|
package/build/ibantools.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* // returns false
|
|
14
14
|
* ibantools.isValidIBAN("NL92ABNA0517164300");
|
|
15
15
|
* ```
|
|
16
|
-
|
|
16
|
+
*/
|
|
17
17
|
export declare function isValidIBAN(iban: string): boolean;
|
|
18
18
|
/**
|
|
19
19
|
* IBAM validation errors
|
|
@@ -24,7 +24,8 @@ export declare enum ValidationErrorsIBAN {
|
|
|
24
24
|
WrongBBANLength = 2,
|
|
25
25
|
WrongBBANFormat = 3,
|
|
26
26
|
ChecksumNotNumber = 4,
|
|
27
|
-
WrongIBANChecksum = 5
|
|
27
|
+
WrongIBANChecksum = 5,
|
|
28
|
+
WrongAccountBankBranchChecksum = 6
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Interface for ValidateIBAN result
|
|
@@ -78,7 +79,7 @@ export interface ComposeIBANParams {
|
|
|
78
79
|
*
|
|
79
80
|
* ```
|
|
80
81
|
* // returns NL91ABNA0417164300
|
|
81
|
-
* ibantools.composeIBAN("NL", "ABNA0417164300");
|
|
82
|
+
* ibantools.composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" });
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
85
|
export declare function composeIBAN(params: ComposeIBANParams): string | null;
|
|
@@ -227,6 +228,7 @@ export interface CountryMap {
|
|
|
227
228
|
interface CountrySpecInternal {
|
|
228
229
|
chars?: number;
|
|
229
230
|
bban_regexp?: string;
|
|
231
|
+
bban_validation_func?: (bban: string) => boolean;
|
|
230
232
|
IBANRegistry?: boolean;
|
|
231
233
|
SEPA?: boolean;
|
|
232
234
|
}
|
package/build/ibantools.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
6
6
|
/**
|
|
7
7
|
* Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff
|
|
8
|
-
* @
|
|
8
|
+
* @package Documentation
|
|
9
9
|
* @author Saša Jovanić
|
|
10
10
|
* @module ibantools
|
|
11
|
-
* @version
|
|
11
|
+
* @version 4.1.0
|
|
12
12
|
* @license MPL-2.0
|
|
13
13
|
* @preferred
|
|
14
14
|
*/
|
|
@@ -25,7 +25,7 @@ exports.countrySpecs = exports.extractBIC = exports.validateBIC = exports.Valida
|
|
|
25
25
|
* // returns false
|
|
26
26
|
* ibantools.isValidIBAN("NL92ABNA0517164300");
|
|
27
27
|
* ```
|
|
28
|
-
|
|
28
|
+
*/
|
|
29
29
|
function isValidIBAN(iban) {
|
|
30
30
|
if (iban !== undefined && iban !== null) {
|
|
31
31
|
var reg = new RegExp('^[0-9]{2}$', '');
|
|
@@ -36,7 +36,7 @@ function isValidIBAN(iban) {
|
|
|
36
36
|
spec.chars &&
|
|
37
37
|
spec.chars === iban.length &&
|
|
38
38
|
reg.test(iban.slice(2, 4)) &&
|
|
39
|
-
|
|
39
|
+
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
|
|
40
40
|
isValidIBANChecksum(iban)) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
@@ -55,6 +55,7 @@ var ValidationErrorsIBAN;
|
|
|
55
55
|
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongBBANFormat"] = 3] = "WrongBBANFormat";
|
|
56
56
|
ValidationErrorsIBAN[ValidationErrorsIBAN["ChecksumNotNumber"] = 4] = "ChecksumNotNumber";
|
|
57
57
|
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongIBANChecksum"] = 5] = "WrongIBANChecksum";
|
|
58
|
+
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongAccountBankBranchChecksum"] = 6] = "WrongAccountBankBranchChecksum";
|
|
58
59
|
})(ValidationErrorsIBAN = exports.ValidationErrorsIBAN || (exports.ValidationErrorsIBAN = {}));
|
|
59
60
|
/**
|
|
60
61
|
* validateIBAN
|
|
@@ -67,28 +68,30 @@ function validateIBAN(iban) {
|
|
|
67
68
|
var result = { errorCodes: [], valid: true };
|
|
68
69
|
if (iban !== undefined && iban !== null && iban !== '') {
|
|
69
70
|
var spec = exports.countrySpecs[iban.slice(0, 2)];
|
|
70
|
-
if (spec
|
|
71
|
+
if (!spec || !(spec.bban_regexp || spec.chars)) {
|
|
71
72
|
result.valid = false;
|
|
72
73
|
result.errorCodes.push(ValidationErrorsIBAN.NoIBANCountry);
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
if (spec && spec.chars && spec.chars !== iban.length) {
|
|
76
|
+
result.valid = false;
|
|
77
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongBBANLength);
|
|
78
|
+
}
|
|
79
|
+
if (spec && spec.bban_regexp && !checkFormatBBAN(iban.slice(4), spec.bban_regexp)) {
|
|
80
|
+
result.valid = false;
|
|
81
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongBBANFormat);
|
|
82
|
+
}
|
|
83
|
+
if (spec && spec.bban_validation_func && !spec.bban_validation_func(iban.slice(4))) {
|
|
84
|
+
result.valid = false;
|
|
85
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongAccountBankBranchChecksum);
|
|
86
|
+
}
|
|
87
|
+
var reg = new RegExp('^[0-9]{2}$', '');
|
|
88
|
+
if (!reg.test(iban.slice(2, 4))) {
|
|
89
|
+
result.valid = false;
|
|
90
|
+
result.errorCodes.push(ValidationErrorsIBAN.ChecksumNotNumber);
|
|
91
|
+
}
|
|
92
|
+
if (!isValidIBANChecksum(iban)) {
|
|
93
|
+
result.valid = false;
|
|
94
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongIBANChecksum);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
@@ -121,6 +124,9 @@ function isValidBBAN(bban, countryCode) {
|
|
|
121
124
|
spec.chars !== null &&
|
|
122
125
|
spec.chars - 4 === bban.length &&
|
|
123
126
|
checkFormatBBAN(bban, spec.bban_regexp)) {
|
|
127
|
+
if (spec.bban_validation_func) {
|
|
128
|
+
return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
|
|
129
|
+
}
|
|
124
130
|
return true;
|
|
125
131
|
}
|
|
126
132
|
}
|
|
@@ -153,7 +159,7 @@ exports.isSEPACountry = isSEPACountry;
|
|
|
153
159
|
*
|
|
154
160
|
* ```
|
|
155
161
|
* // returns NL91ABNA0417164300
|
|
156
|
-
* ibantools.composeIBAN("NL", "ABNA0417164300");
|
|
162
|
+
* ibantools.composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" });
|
|
157
163
|
* ```
|
|
158
164
|
*/
|
|
159
165
|
function composeIBAN(params) {
|
|
@@ -170,7 +176,7 @@ function composeIBAN(params) {
|
|
|
170
176
|
spec.bban_regexp &&
|
|
171
177
|
spec.bban_regexp !== null &&
|
|
172
178
|
checkFormatBBAN(formated_bban, spec.bban_regexp)) {
|
|
173
|
-
var checksom =
|
|
179
|
+
var checksom = mod9710Iban(params.countryCode + '00' + formated_bban);
|
|
174
180
|
return params.countryCode + ('0' + (98 - checksom)).slice(-2) + formated_bban;
|
|
175
181
|
}
|
|
176
182
|
return null;
|
|
@@ -243,6 +249,7 @@ function friendlyFormatIBAN(iban, separator) {
|
|
|
243
249
|
separator = ' ';
|
|
244
250
|
}
|
|
245
251
|
var electronic_iban = electronicFormatIBAN(iban);
|
|
252
|
+
/* istanbul ignore if */
|
|
246
253
|
if (electronic_iban === null) {
|
|
247
254
|
return null;
|
|
248
255
|
}
|
|
@@ -279,7 +286,7 @@ function isValidIBANChecksum(iban) {
|
|
|
279
286
|
*
|
|
280
287
|
* @ignore
|
|
281
288
|
*/
|
|
282
|
-
function
|
|
289
|
+
function mod9710Iban(iban) {
|
|
283
290
|
iban = iban.slice(3) + iban.slice(0, 4);
|
|
284
291
|
var validationString = '';
|
|
285
292
|
for (var n = 1; n < iban.length; n++) {
|
|
@@ -291,11 +298,7 @@ function mod9710(iban) {
|
|
|
291
298
|
validationString += iban[n];
|
|
292
299
|
}
|
|
293
300
|
}
|
|
294
|
-
|
|
295
|
-
var part = validationString.slice(0, 6);
|
|
296
|
-
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
|
|
297
|
-
}
|
|
298
|
-
return parseInt(validationString, 10) % 97;
|
|
301
|
+
return mod9710(validationString);
|
|
299
302
|
}
|
|
300
303
|
/**
|
|
301
304
|
* Returns specifications for all countries, even those who are not
|
|
@@ -422,6 +425,126 @@ function extractBIC(inputBic) {
|
|
|
422
425
|
return result;
|
|
423
426
|
}
|
|
424
427
|
exports.extractBIC = extractBIC;
|
|
428
|
+
/**
|
|
429
|
+
* Used for Norway BBAN check
|
|
430
|
+
*
|
|
431
|
+
* @ignore
|
|
432
|
+
*/
|
|
433
|
+
var checkNorwayBBAN = function (bban) {
|
|
434
|
+
var weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
435
|
+
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
|
|
436
|
+
if (bbanWithoutSpacesAndPeriods.length !== 11) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
var controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
|
|
441
|
+
var bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
|
|
442
|
+
var sum = 0;
|
|
443
|
+
for (var index = 0; index < 10; index++) {
|
|
444
|
+
sum += parseInt(bbanWithoutControlDigit.charAt(index), 10) * weights[index];
|
|
445
|
+
}
|
|
446
|
+
var remainder = sum % 11;
|
|
447
|
+
return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Used for Netherlands BBAN check
|
|
452
|
+
*
|
|
453
|
+
* @ignore
|
|
454
|
+
*/
|
|
455
|
+
var checkDutchBBAN = function (bban) {
|
|
456
|
+
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
|
|
457
|
+
var accountNumber = bbanWithoutSpacesAndPeriods.substring(4, 14);
|
|
458
|
+
if (accountNumber.startsWith('000')) {
|
|
459
|
+
return true; // Postbank account, no `elfproef` possible
|
|
460
|
+
}
|
|
461
|
+
var sum = 0;
|
|
462
|
+
for (var index = 0; index < 10; index++) {
|
|
463
|
+
sum += parseInt(accountNumber.charAt(index), 10) * (10 - index);
|
|
464
|
+
}
|
|
465
|
+
return sum % 11 === 0;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Used for Belgian BBAN check
|
|
469
|
+
*
|
|
470
|
+
* @ignore
|
|
471
|
+
*/
|
|
472
|
+
var checkBelgianBBAN = function (bban) {
|
|
473
|
+
var stripped = bban.replace(/[\s.]+/g, '');
|
|
474
|
+
var checkingPart = parseInt(stripped.substring(0, stripped.length - 2), 10);
|
|
475
|
+
var checksum = parseInt(stripped.substring(stripped.length - 2, stripped.length), 10);
|
|
476
|
+
var reminder = checkingPart % 97;
|
|
477
|
+
if (reminder === 0) {
|
|
478
|
+
reminder = 97;
|
|
479
|
+
}
|
|
480
|
+
return reminder === checksum;
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* Mod 97/10 calculation
|
|
484
|
+
*
|
|
485
|
+
* @ignore
|
|
486
|
+
*/
|
|
487
|
+
var mod9710 = function (validationString) {
|
|
488
|
+
while (validationString.length > 2) {
|
|
489
|
+
var part = validationString.slice(0, 6);
|
|
490
|
+
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
|
|
491
|
+
}
|
|
492
|
+
return parseInt(validationString, 10) % 97;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Check BBAN based on Mod97/10 calculation for countries that support it:
|
|
496
|
+
* BA, ME, MK, PT, RS, SI
|
|
497
|
+
*
|
|
498
|
+
* @ignore
|
|
499
|
+
*/
|
|
500
|
+
var checkMod9710BBAN = function (bban) {
|
|
501
|
+
var stripped = bban.replace(/[\s.]+/g, '');
|
|
502
|
+
var reminder = mod9710(stripped);
|
|
503
|
+
return reminder === 1;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Used for Poland BBAN check
|
|
507
|
+
*
|
|
508
|
+
* @ignore
|
|
509
|
+
*/
|
|
510
|
+
var checkPolandBBAN = function (bban) {
|
|
511
|
+
var weights = [3, 9, 7, 1, 3, 9, 7];
|
|
512
|
+
var controlDigit = parseInt(bban.charAt(7), 10);
|
|
513
|
+
var toCheck = bban.substring(0, 7);
|
|
514
|
+
var sum = 0;
|
|
515
|
+
for (var index = 0; index < 7; index++) {
|
|
516
|
+
sum += parseInt(toCheck.charAt(index), 10) * weights[index];
|
|
517
|
+
}
|
|
518
|
+
var remainder = sum % 10;
|
|
519
|
+
return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Spain (ES) BBAN check
|
|
523
|
+
*
|
|
524
|
+
* @ignore
|
|
525
|
+
*/
|
|
526
|
+
var checkSpainBBAN = function (bban) {
|
|
527
|
+
var weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
|
|
528
|
+
var weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
|
|
529
|
+
var controlBankBranch = parseInt(bban.charAt(8), 10);
|
|
530
|
+
var controlAccount = parseInt(bban.charAt(9), 10);
|
|
531
|
+
var bankBranch = bban.substring(0, 8);
|
|
532
|
+
var account = bban.substring(10, 20);
|
|
533
|
+
var sum = 0;
|
|
534
|
+
for (var index = 0; index < 8; index++) {
|
|
535
|
+
sum += parseInt(bankBranch.charAt(index), 10) * weightsBankBranch[index];
|
|
536
|
+
}
|
|
537
|
+
var remainder = sum % 11;
|
|
538
|
+
if (controlBankBranch !== (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder)) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
sum = 0;
|
|
542
|
+
for (var index = 0; index < 10; index++) {
|
|
543
|
+
sum += parseInt(account.charAt(index), 10) * weightsAccount[index];
|
|
544
|
+
}
|
|
545
|
+
remainder = sum % 11;
|
|
546
|
+
return controlAccount === (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder);
|
|
547
|
+
};
|
|
425
548
|
/**
|
|
426
549
|
* Country specifications
|
|
427
550
|
*/
|
|
@@ -430,6 +553,7 @@ exports.countrySpecs = {
|
|
|
430
553
|
chars: 24,
|
|
431
554
|
bban_regexp: '^[0-9]{8}[A-Z0-9]{12}$',
|
|
432
555
|
IBANRegistry: true,
|
|
556
|
+
SEPA: true,
|
|
433
557
|
},
|
|
434
558
|
AE: {
|
|
435
559
|
chars: 23,
|
|
@@ -468,11 +592,12 @@ exports.countrySpecs = {
|
|
|
468
592
|
BA: {
|
|
469
593
|
chars: 20,
|
|
470
594
|
bban_regexp: '^[0-9]{16}$',
|
|
595
|
+
bban_validation_func: checkMod9710BBAN,
|
|
471
596
|
IBANRegistry: true,
|
|
472
597
|
},
|
|
473
598
|
BB: {},
|
|
474
599
|
BD: {},
|
|
475
|
-
BE: { chars: 16, bban_regexp: '^[0-9]{12}$', IBANRegistry: true, SEPA: true },
|
|
600
|
+
BE: { chars: 16, bban_regexp: '^[0-9]{12}$', bban_validation_func: checkBelgianBBAN, IBANRegistry: true, SEPA: true },
|
|
476
601
|
BF: {
|
|
477
602
|
chars: 28,
|
|
478
603
|
bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
|
|
@@ -481,6 +606,7 @@ exports.countrySpecs = {
|
|
|
481
606
|
chars: 22,
|
|
482
607
|
bban_regexp: '^[A-Z]{4}[0-9]{6}[A-Z0-9]{8}$',
|
|
483
608
|
IBANRegistry: true,
|
|
609
|
+
SEPA: true,
|
|
484
610
|
},
|
|
485
611
|
BH: {
|
|
486
612
|
chars: 22,
|
|
@@ -488,8 +614,8 @@ exports.countrySpecs = {
|
|
|
488
614
|
IBANRegistry: true,
|
|
489
615
|
},
|
|
490
616
|
BI: {
|
|
491
|
-
chars:
|
|
492
|
-
bban_regexp: '^[0-9]{
|
|
617
|
+
chars: 27,
|
|
618
|
+
bban_regexp: '^[0-9]{23}$',
|
|
493
619
|
},
|
|
494
620
|
BJ: {
|
|
495
621
|
chars: 28,
|
|
@@ -585,13 +711,13 @@ exports.countrySpecs = {
|
|
|
585
711
|
EG: { chars: 29, bban_regexp: '^[0-9]{25}', IBANRegistry: true },
|
|
586
712
|
EH: {},
|
|
587
713
|
ER: {},
|
|
588
|
-
ES: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
714
|
+
ES: { chars: 24, bban_validation_func: checkSpainBBAN, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
589
715
|
ET: {},
|
|
590
716
|
FI: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true, SEPA: true },
|
|
591
717
|
FJ: {},
|
|
592
718
|
FK: {},
|
|
593
719
|
FM: {},
|
|
594
|
-
FO: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true
|
|
720
|
+
FO: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true },
|
|
595
721
|
FR: {
|
|
596
722
|
chars: 27,
|
|
597
723
|
bban_regexp: '^[0-9]{10}[A-Z0-9]{11}[0-9]{2}$',
|
|
@@ -627,7 +753,7 @@ exports.countrySpecs = {
|
|
|
627
753
|
IBANRegistry: true,
|
|
628
754
|
SEPA: true,
|
|
629
755
|
},
|
|
630
|
-
GL: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true
|
|
756
|
+
GL: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true },
|
|
631
757
|
GM: {},
|
|
632
758
|
GN: {},
|
|
633
759
|
GP: {
|
|
@@ -783,6 +909,7 @@ exports.countrySpecs = {
|
|
|
783
909
|
ME: {
|
|
784
910
|
chars: 22,
|
|
785
911
|
bban_regexp: '^[0-9]{18}$',
|
|
912
|
+
bban_validation_func: checkMod9710BBAN,
|
|
786
913
|
IBANRegistry: true,
|
|
787
914
|
},
|
|
788
915
|
MF: {
|
|
@@ -798,6 +925,7 @@ exports.countrySpecs = {
|
|
|
798
925
|
MK: {
|
|
799
926
|
chars: 19,
|
|
800
927
|
bban_regexp: '^[0-9]{3}[A-Z0-9]{10}[0-9]{2}$',
|
|
928
|
+
bban_validation_func: checkMod9710BBAN,
|
|
801
929
|
IBANRegistry: true,
|
|
802
930
|
},
|
|
803
931
|
ML: {
|
|
@@ -857,10 +985,11 @@ exports.countrySpecs = {
|
|
|
857
985
|
NL: {
|
|
858
986
|
chars: 18,
|
|
859
987
|
bban_regexp: '^[A-Z]{4}[0-9]{10}$',
|
|
988
|
+
bban_validation_func: checkDutchBBAN,
|
|
860
989
|
IBANRegistry: true,
|
|
861
990
|
SEPA: true,
|
|
862
991
|
},
|
|
863
|
-
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', IBANRegistry: true, SEPA: true },
|
|
992
|
+
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
|
|
864
993
|
NP: {},
|
|
865
994
|
NR: {},
|
|
866
995
|
NU: {},
|
|
@@ -880,7 +1009,7 @@ exports.countrySpecs = {
|
|
|
880
1009
|
bban_regexp: '^[A-Z0-9]{4}[0-9]{16}$',
|
|
881
1010
|
IBANRegistry: true,
|
|
882
1011
|
},
|
|
883
|
-
PL: { chars: 28, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
|
|
1012
|
+
PL: { chars: 28, bban_validation_func: checkPolandBBAN, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
|
|
884
1013
|
PM: {
|
|
885
1014
|
chars: 27,
|
|
886
1015
|
bban_regexp: '^[0-9]{10}[A-Z0-9]{11}[0-9]{2}$',
|
|
@@ -893,7 +1022,7 @@ exports.countrySpecs = {
|
|
|
893
1022
|
bban_regexp: '^[A-Z0-9]{4}[0-9]{21}$',
|
|
894
1023
|
IBANRegistry: true,
|
|
895
1024
|
},
|
|
896
|
-
PT: { chars: 25, bban_regexp: '^[0-9]{21}$', IBANRegistry: true, SEPA: true },
|
|
1025
|
+
PT: { chars: 25, bban_regexp: '^[0-9]{21}$', bban_validation_func: checkMod9710BBAN, IBANRegistry: true, SEPA: true },
|
|
897
1026
|
PW: {},
|
|
898
1027
|
PY: {},
|
|
899
1028
|
QA: {
|
|
@@ -915,6 +1044,7 @@ exports.countrySpecs = {
|
|
|
915
1044
|
RS: {
|
|
916
1045
|
chars: 22,
|
|
917
1046
|
bban_regexp: '^[0-9]{18}$',
|
|
1047
|
+
bban_validation_func: checkMod9710BBAN,
|
|
918
1048
|
IBANRegistry: true,
|
|
919
1049
|
},
|
|
920
1050
|
RU: {},
|
|
@@ -934,7 +1064,13 @@ exports.countrySpecs = {
|
|
|
934
1064
|
SE: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
935
1065
|
SG: {},
|
|
936
1066
|
SH: {},
|
|
937
|
-
SI: {
|
|
1067
|
+
SI: {
|
|
1068
|
+
chars: 19,
|
|
1069
|
+
bban_regexp: '^[0-9]{15}$',
|
|
1070
|
+
bban_validation_func: checkMod9710BBAN,
|
|
1071
|
+
IBANRegistry: true,
|
|
1072
|
+
SEPA: true,
|
|
1073
|
+
},
|
|
938
1074
|
SJ: {},
|
|
939
1075
|
SK: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
940
1076
|
SL: {},
|
|
@@ -946,7 +1082,7 @@ exports.countrySpecs = {
|
|
|
946
1082
|
},
|
|
947
1083
|
SN: {
|
|
948
1084
|
chars: 28,
|
|
949
|
-
bban_regexp: '^[A-Z]{
|
|
1085
|
+
bban_regexp: '^[A-Z]{2}[0-9]{22}$',
|
|
950
1086
|
},
|
|
951
1087
|
SO: {},
|
|
952
1088
|
SR: {},
|
package/jsnext/ibantools.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
6
6
|
/**
|
|
7
7
|
* Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff
|
|
8
|
-
* @
|
|
8
|
+
* @package Documentation
|
|
9
9
|
* @author Saša Jovanić
|
|
10
10
|
* @module ibantools
|
|
11
|
-
* @version
|
|
11
|
+
* @version 4.1.0
|
|
12
12
|
* @license MPL-2.0
|
|
13
13
|
* @preferred
|
|
14
14
|
*/
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* // returns false
|
|
24
24
|
* ibantools.isValidIBAN("NL92ABNA0517164300");
|
|
25
25
|
* ```
|
|
26
|
-
|
|
26
|
+
*/
|
|
27
27
|
export function isValidIBAN(iban) {
|
|
28
28
|
if (iban !== undefined && iban !== null) {
|
|
29
29
|
var reg = new RegExp('^[0-9]{2}$', '');
|
|
@@ -34,7 +34,7 @@ export function isValidIBAN(iban) {
|
|
|
34
34
|
spec.chars &&
|
|
35
35
|
spec.chars === iban.length &&
|
|
36
36
|
reg.test(iban.slice(2, 4)) &&
|
|
37
|
-
|
|
37
|
+
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
|
|
38
38
|
isValidIBANChecksum(iban)) {
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
@@ -52,6 +52,7 @@ export var ValidationErrorsIBAN;
|
|
|
52
52
|
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongBBANFormat"] = 3] = "WrongBBANFormat";
|
|
53
53
|
ValidationErrorsIBAN[ValidationErrorsIBAN["ChecksumNotNumber"] = 4] = "ChecksumNotNumber";
|
|
54
54
|
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongIBANChecksum"] = 5] = "WrongIBANChecksum";
|
|
55
|
+
ValidationErrorsIBAN[ValidationErrorsIBAN["WrongAccountBankBranchChecksum"] = 6] = "WrongAccountBankBranchChecksum";
|
|
55
56
|
})(ValidationErrorsIBAN || (ValidationErrorsIBAN = {}));
|
|
56
57
|
/**
|
|
57
58
|
* validateIBAN
|
|
@@ -64,28 +65,30 @@ export function validateIBAN(iban) {
|
|
|
64
65
|
var result = { errorCodes: [], valid: true };
|
|
65
66
|
if (iban !== undefined && iban !== null && iban !== '') {
|
|
66
67
|
var spec = countrySpecs[iban.slice(0, 2)];
|
|
67
|
-
if (spec
|
|
68
|
+
if (!spec || !(spec.bban_regexp || spec.chars)) {
|
|
68
69
|
result.valid = false;
|
|
69
70
|
result.errorCodes.push(ValidationErrorsIBAN.NoIBANCountry);
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
if (spec && spec.chars && spec.chars !== iban.length) {
|
|
73
|
+
result.valid = false;
|
|
74
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongBBANLength);
|
|
75
|
+
}
|
|
76
|
+
if (spec && spec.bban_regexp && !checkFormatBBAN(iban.slice(4), spec.bban_regexp)) {
|
|
77
|
+
result.valid = false;
|
|
78
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongBBANFormat);
|
|
79
|
+
}
|
|
80
|
+
if (spec && spec.bban_validation_func && !spec.bban_validation_func(iban.slice(4))) {
|
|
81
|
+
result.valid = false;
|
|
82
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongAccountBankBranchChecksum);
|
|
83
|
+
}
|
|
84
|
+
var reg = new RegExp('^[0-9]{2}$', '');
|
|
85
|
+
if (!reg.test(iban.slice(2, 4))) {
|
|
86
|
+
result.valid = false;
|
|
87
|
+
result.errorCodes.push(ValidationErrorsIBAN.ChecksumNotNumber);
|
|
88
|
+
}
|
|
89
|
+
if (!isValidIBANChecksum(iban)) {
|
|
90
|
+
result.valid = false;
|
|
91
|
+
result.errorCodes.push(ValidationErrorsIBAN.WrongIBANChecksum);
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
else {
|
|
@@ -117,6 +120,9 @@ export function isValidBBAN(bban, countryCode) {
|
|
|
117
120
|
spec.chars !== null &&
|
|
118
121
|
spec.chars - 4 === bban.length &&
|
|
119
122
|
checkFormatBBAN(bban, spec.bban_regexp)) {
|
|
123
|
+
if (spec.bban_validation_func) {
|
|
124
|
+
return spec.bban_validation_func(bban.replace(/[\s.]+/g, ''));
|
|
125
|
+
}
|
|
120
126
|
return true;
|
|
121
127
|
}
|
|
122
128
|
}
|
|
@@ -147,7 +153,7 @@ export function isSEPACountry(countryCode) {
|
|
|
147
153
|
*
|
|
148
154
|
* ```
|
|
149
155
|
* // returns NL91ABNA0417164300
|
|
150
|
-
* ibantools.composeIBAN("NL", "ABNA0417164300");
|
|
156
|
+
* ibantools.composeIBAN({ countryCode: "NL", bban: "ABNA0417164300" });
|
|
151
157
|
* ```
|
|
152
158
|
*/
|
|
153
159
|
export function composeIBAN(params) {
|
|
@@ -164,7 +170,7 @@ export function composeIBAN(params) {
|
|
|
164
170
|
spec.bban_regexp &&
|
|
165
171
|
spec.bban_regexp !== null &&
|
|
166
172
|
checkFormatBBAN(formated_bban, spec.bban_regexp)) {
|
|
167
|
-
var checksom =
|
|
173
|
+
var checksom = mod9710Iban(params.countryCode + '00' + formated_bban);
|
|
168
174
|
return params.countryCode + ('0' + (98 - checksom)).slice(-2) + formated_bban;
|
|
169
175
|
}
|
|
170
176
|
return null;
|
|
@@ -234,6 +240,7 @@ export function friendlyFormatIBAN(iban, separator) {
|
|
|
234
240
|
separator = ' ';
|
|
235
241
|
}
|
|
236
242
|
var electronic_iban = electronicFormatIBAN(iban);
|
|
243
|
+
/* istanbul ignore if */
|
|
237
244
|
if (electronic_iban === null) {
|
|
238
245
|
return null;
|
|
239
246
|
}
|
|
@@ -269,7 +276,7 @@ function isValidIBANChecksum(iban) {
|
|
|
269
276
|
*
|
|
270
277
|
* @ignore
|
|
271
278
|
*/
|
|
272
|
-
function
|
|
279
|
+
function mod9710Iban(iban) {
|
|
273
280
|
iban = iban.slice(3) + iban.slice(0, 4);
|
|
274
281
|
var validationString = '';
|
|
275
282
|
for (var n = 1; n < iban.length; n++) {
|
|
@@ -281,11 +288,7 @@ function mod9710(iban) {
|
|
|
281
288
|
validationString += iban[n];
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
|
-
|
|
285
|
-
var part = validationString.slice(0, 6);
|
|
286
|
-
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
|
|
287
|
-
}
|
|
288
|
-
return parseInt(validationString, 10) % 97;
|
|
291
|
+
return mod9710(validationString);
|
|
289
292
|
}
|
|
290
293
|
/**
|
|
291
294
|
* Returns specifications for all countries, even those who are not
|
|
@@ -408,6 +411,126 @@ export function extractBIC(inputBic) {
|
|
|
408
411
|
}
|
|
409
412
|
return result;
|
|
410
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Used for Norway BBAN check
|
|
416
|
+
*
|
|
417
|
+
* @ignore
|
|
418
|
+
*/
|
|
419
|
+
var checkNorwayBBAN = function (bban) {
|
|
420
|
+
var weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
421
|
+
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
|
|
422
|
+
if (bbanWithoutSpacesAndPeriods.length !== 11) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
var controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
|
|
427
|
+
var bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
|
|
428
|
+
var sum = 0;
|
|
429
|
+
for (var index = 0; index < 10; index++) {
|
|
430
|
+
sum += parseInt(bbanWithoutControlDigit.charAt(index), 10) * weights[index];
|
|
431
|
+
}
|
|
432
|
+
var remainder = sum % 11;
|
|
433
|
+
return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Used for Netherlands BBAN check
|
|
438
|
+
*
|
|
439
|
+
* @ignore
|
|
440
|
+
*/
|
|
441
|
+
var checkDutchBBAN = function (bban) {
|
|
442
|
+
var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
|
|
443
|
+
var accountNumber = bbanWithoutSpacesAndPeriods.substring(4, 14);
|
|
444
|
+
if (accountNumber.startsWith('000')) {
|
|
445
|
+
return true; // Postbank account, no `elfproef` possible
|
|
446
|
+
}
|
|
447
|
+
var sum = 0;
|
|
448
|
+
for (var index = 0; index < 10; index++) {
|
|
449
|
+
sum += parseInt(accountNumber.charAt(index), 10) * (10 - index);
|
|
450
|
+
}
|
|
451
|
+
return sum % 11 === 0;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* Used for Belgian BBAN check
|
|
455
|
+
*
|
|
456
|
+
* @ignore
|
|
457
|
+
*/
|
|
458
|
+
var checkBelgianBBAN = function (bban) {
|
|
459
|
+
var stripped = bban.replace(/[\s.]+/g, '');
|
|
460
|
+
var checkingPart = parseInt(stripped.substring(0, stripped.length - 2), 10);
|
|
461
|
+
var checksum = parseInt(stripped.substring(stripped.length - 2, stripped.length), 10);
|
|
462
|
+
var reminder = checkingPart % 97;
|
|
463
|
+
if (reminder === 0) {
|
|
464
|
+
reminder = 97;
|
|
465
|
+
}
|
|
466
|
+
return reminder === checksum;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Mod 97/10 calculation
|
|
470
|
+
*
|
|
471
|
+
* @ignore
|
|
472
|
+
*/
|
|
473
|
+
var mod9710 = function (validationString) {
|
|
474
|
+
while (validationString.length > 2) {
|
|
475
|
+
var part = validationString.slice(0, 6);
|
|
476
|
+
validationString = (parseInt(part, 10) % 97).toString() + validationString.slice(part.length);
|
|
477
|
+
}
|
|
478
|
+
return parseInt(validationString, 10) % 97;
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* Check BBAN based on Mod97/10 calculation for countries that support it:
|
|
482
|
+
* BA, ME, MK, PT, RS, SI
|
|
483
|
+
*
|
|
484
|
+
* @ignore
|
|
485
|
+
*/
|
|
486
|
+
var checkMod9710BBAN = function (bban) {
|
|
487
|
+
var stripped = bban.replace(/[\s.]+/g, '');
|
|
488
|
+
var reminder = mod9710(stripped);
|
|
489
|
+
return reminder === 1;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Used for Poland BBAN check
|
|
493
|
+
*
|
|
494
|
+
* @ignore
|
|
495
|
+
*/
|
|
496
|
+
var checkPolandBBAN = function (bban) {
|
|
497
|
+
var weights = [3, 9, 7, 1, 3, 9, 7];
|
|
498
|
+
var controlDigit = parseInt(bban.charAt(7), 10);
|
|
499
|
+
var toCheck = bban.substring(0, 7);
|
|
500
|
+
var sum = 0;
|
|
501
|
+
for (var index = 0; index < 7; index++) {
|
|
502
|
+
sum += parseInt(toCheck.charAt(index), 10) * weights[index];
|
|
503
|
+
}
|
|
504
|
+
var remainder = sum % 10;
|
|
505
|
+
return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Spain (ES) BBAN check
|
|
509
|
+
*
|
|
510
|
+
* @ignore
|
|
511
|
+
*/
|
|
512
|
+
var checkSpainBBAN = function (bban) {
|
|
513
|
+
var weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
|
|
514
|
+
var weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
|
|
515
|
+
var controlBankBranch = parseInt(bban.charAt(8), 10);
|
|
516
|
+
var controlAccount = parseInt(bban.charAt(9), 10);
|
|
517
|
+
var bankBranch = bban.substring(0, 8);
|
|
518
|
+
var account = bban.substring(10, 20);
|
|
519
|
+
var sum = 0;
|
|
520
|
+
for (var index = 0; index < 8; index++) {
|
|
521
|
+
sum += parseInt(bankBranch.charAt(index), 10) * weightsBankBranch[index];
|
|
522
|
+
}
|
|
523
|
+
var remainder = sum % 11;
|
|
524
|
+
if (controlBankBranch !== (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder)) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
sum = 0;
|
|
528
|
+
for (var index = 0; index < 10; index++) {
|
|
529
|
+
sum += parseInt(account.charAt(index), 10) * weightsAccount[index];
|
|
530
|
+
}
|
|
531
|
+
remainder = sum % 11;
|
|
532
|
+
return controlAccount === (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder);
|
|
533
|
+
};
|
|
411
534
|
/**
|
|
412
535
|
* Country specifications
|
|
413
536
|
*/
|
|
@@ -416,6 +539,7 @@ export var countrySpecs = {
|
|
|
416
539
|
chars: 24,
|
|
417
540
|
bban_regexp: '^[0-9]{8}[A-Z0-9]{12}$',
|
|
418
541
|
IBANRegistry: true,
|
|
542
|
+
SEPA: true,
|
|
419
543
|
},
|
|
420
544
|
AE: {
|
|
421
545
|
chars: 23,
|
|
@@ -454,11 +578,12 @@ export var countrySpecs = {
|
|
|
454
578
|
BA: {
|
|
455
579
|
chars: 20,
|
|
456
580
|
bban_regexp: '^[0-9]{16}$',
|
|
581
|
+
bban_validation_func: checkMod9710BBAN,
|
|
457
582
|
IBANRegistry: true,
|
|
458
583
|
},
|
|
459
584
|
BB: {},
|
|
460
585
|
BD: {},
|
|
461
|
-
BE: { chars: 16, bban_regexp: '^[0-9]{12}$', IBANRegistry: true, SEPA: true },
|
|
586
|
+
BE: { chars: 16, bban_regexp: '^[0-9]{12}$', bban_validation_func: checkBelgianBBAN, IBANRegistry: true, SEPA: true },
|
|
462
587
|
BF: {
|
|
463
588
|
chars: 28,
|
|
464
589
|
bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
|
|
@@ -467,6 +592,7 @@ export var countrySpecs = {
|
|
|
467
592
|
chars: 22,
|
|
468
593
|
bban_regexp: '^[A-Z]{4}[0-9]{6}[A-Z0-9]{8}$',
|
|
469
594
|
IBANRegistry: true,
|
|
595
|
+
SEPA: true,
|
|
470
596
|
},
|
|
471
597
|
BH: {
|
|
472
598
|
chars: 22,
|
|
@@ -474,8 +600,8 @@ export var countrySpecs = {
|
|
|
474
600
|
IBANRegistry: true,
|
|
475
601
|
},
|
|
476
602
|
BI: {
|
|
477
|
-
chars:
|
|
478
|
-
bban_regexp: '^[0-9]{
|
|
603
|
+
chars: 27,
|
|
604
|
+
bban_regexp: '^[0-9]{23}$',
|
|
479
605
|
},
|
|
480
606
|
BJ: {
|
|
481
607
|
chars: 28,
|
|
@@ -571,13 +697,13 @@ export var countrySpecs = {
|
|
|
571
697
|
EG: { chars: 29, bban_regexp: '^[0-9]{25}', IBANRegistry: true },
|
|
572
698
|
EH: {},
|
|
573
699
|
ER: {},
|
|
574
|
-
ES: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
700
|
+
ES: { chars: 24, bban_validation_func: checkSpainBBAN, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
575
701
|
ET: {},
|
|
576
702
|
FI: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true, SEPA: true },
|
|
577
703
|
FJ: {},
|
|
578
704
|
FK: {},
|
|
579
705
|
FM: {},
|
|
580
|
-
FO: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true
|
|
706
|
+
FO: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true },
|
|
581
707
|
FR: {
|
|
582
708
|
chars: 27,
|
|
583
709
|
bban_regexp: '^[0-9]{10}[A-Z0-9]{11}[0-9]{2}$',
|
|
@@ -613,7 +739,7 @@ export var countrySpecs = {
|
|
|
613
739
|
IBANRegistry: true,
|
|
614
740
|
SEPA: true,
|
|
615
741
|
},
|
|
616
|
-
GL: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true
|
|
742
|
+
GL: { chars: 18, bban_regexp: '^[0-9]{14}$', IBANRegistry: true },
|
|
617
743
|
GM: {},
|
|
618
744
|
GN: {},
|
|
619
745
|
GP: {
|
|
@@ -769,6 +895,7 @@ export var countrySpecs = {
|
|
|
769
895
|
ME: {
|
|
770
896
|
chars: 22,
|
|
771
897
|
bban_regexp: '^[0-9]{18}$',
|
|
898
|
+
bban_validation_func: checkMod9710BBAN,
|
|
772
899
|
IBANRegistry: true,
|
|
773
900
|
},
|
|
774
901
|
MF: {
|
|
@@ -784,6 +911,7 @@ export var countrySpecs = {
|
|
|
784
911
|
MK: {
|
|
785
912
|
chars: 19,
|
|
786
913
|
bban_regexp: '^[0-9]{3}[A-Z0-9]{10}[0-9]{2}$',
|
|
914
|
+
bban_validation_func: checkMod9710BBAN,
|
|
787
915
|
IBANRegistry: true,
|
|
788
916
|
},
|
|
789
917
|
ML: {
|
|
@@ -843,10 +971,11 @@ export var countrySpecs = {
|
|
|
843
971
|
NL: {
|
|
844
972
|
chars: 18,
|
|
845
973
|
bban_regexp: '^[A-Z]{4}[0-9]{10}$',
|
|
974
|
+
bban_validation_func: checkDutchBBAN,
|
|
846
975
|
IBANRegistry: true,
|
|
847
976
|
SEPA: true,
|
|
848
977
|
},
|
|
849
|
-
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', IBANRegistry: true, SEPA: true },
|
|
978
|
+
NO: { chars: 15, bban_regexp: '^[0-9]{11}$', bban_validation_func: checkNorwayBBAN, IBANRegistry: true, SEPA: true },
|
|
850
979
|
NP: {},
|
|
851
980
|
NR: {},
|
|
852
981
|
NU: {},
|
|
@@ -866,7 +995,7 @@ export var countrySpecs = {
|
|
|
866
995
|
bban_regexp: '^[A-Z0-9]{4}[0-9]{16}$',
|
|
867
996
|
IBANRegistry: true,
|
|
868
997
|
},
|
|
869
|
-
PL: { chars: 28, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
|
|
998
|
+
PL: { chars: 28, bban_validation_func: checkPolandBBAN, bban_regexp: '^[0-9]{24}$', IBANRegistry: true, SEPA: true },
|
|
870
999
|
PM: {
|
|
871
1000
|
chars: 27,
|
|
872
1001
|
bban_regexp: '^[0-9]{10}[A-Z0-9]{11}[0-9]{2}$',
|
|
@@ -879,7 +1008,7 @@ export var countrySpecs = {
|
|
|
879
1008
|
bban_regexp: '^[A-Z0-9]{4}[0-9]{21}$',
|
|
880
1009
|
IBANRegistry: true,
|
|
881
1010
|
},
|
|
882
|
-
PT: { chars: 25, bban_regexp: '^[0-9]{21}$', IBANRegistry: true, SEPA: true },
|
|
1011
|
+
PT: { chars: 25, bban_regexp: '^[0-9]{21}$', bban_validation_func: checkMod9710BBAN, IBANRegistry: true, SEPA: true },
|
|
883
1012
|
PW: {},
|
|
884
1013
|
PY: {},
|
|
885
1014
|
QA: {
|
|
@@ -901,6 +1030,7 @@ export var countrySpecs = {
|
|
|
901
1030
|
RS: {
|
|
902
1031
|
chars: 22,
|
|
903
1032
|
bban_regexp: '^[0-9]{18}$',
|
|
1033
|
+
bban_validation_func: checkMod9710BBAN,
|
|
904
1034
|
IBANRegistry: true,
|
|
905
1035
|
},
|
|
906
1036
|
RU: {},
|
|
@@ -920,7 +1050,13 @@ export var countrySpecs = {
|
|
|
920
1050
|
SE: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
921
1051
|
SG: {},
|
|
922
1052
|
SH: {},
|
|
923
|
-
SI: {
|
|
1053
|
+
SI: {
|
|
1054
|
+
chars: 19,
|
|
1055
|
+
bban_regexp: '^[0-9]{15}$',
|
|
1056
|
+
bban_validation_func: checkMod9710BBAN,
|
|
1057
|
+
IBANRegistry: true,
|
|
1058
|
+
SEPA: true,
|
|
1059
|
+
},
|
|
924
1060
|
SJ: {},
|
|
925
1061
|
SK: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true },
|
|
926
1062
|
SL: {},
|
|
@@ -932,7 +1068,7 @@ export var countrySpecs = {
|
|
|
932
1068
|
},
|
|
933
1069
|
SN: {
|
|
934
1070
|
chars: 28,
|
|
935
|
-
bban_regexp: '^[A-Z]{
|
|
1071
|
+
bban_regexp: '^[A-Z]{2}[0-9]{22}$',
|
|
936
1072
|
},
|
|
937
1073
|
SO: {},
|
|
938
1074
|
SR: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ibantools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff like ISO 3136-1 alpha 2 country list",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"IBAN",
|
|
@@ -50,32 +50,32 @@
|
|
|
50
50
|
},
|
|
51
51
|
"license": "MPL-2.0",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
54
|
-
"@typescript-eslint/parser": "^4.
|
|
55
|
-
"chai": "^4.
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
|
54
|
+
"@typescript-eslint/parser": "^4.28.4",
|
|
55
|
+
"chai": "^4.3.4",
|
|
56
56
|
"cheerio": "^0.22",
|
|
57
|
-
"coveralls": "^3.1.
|
|
57
|
+
"coveralls": "^3.1.1",
|
|
58
58
|
"docdash": "^1.2.0",
|
|
59
|
-
"eslint": "^7.
|
|
60
|
-
"eslint-config-prettier": "^8.
|
|
61
|
-
"eslint-plugin-prettier": "^
|
|
59
|
+
"eslint": "^7.31.0",
|
|
60
|
+
"eslint-config-prettier": "^8.3.0",
|
|
61
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
62
62
|
"gulp": "^4.0.2",
|
|
63
63
|
"gulp-mocha": "^8.0",
|
|
64
64
|
"gulp-rename": "^2.0",
|
|
65
65
|
"gulp-shell": "^0.8.0",
|
|
66
66
|
"gulp-typescript": "^5.0",
|
|
67
|
-
"jasmine-core": "^3.
|
|
68
|
-
"karma": "^6.
|
|
67
|
+
"jasmine-core": "^3.8.0",
|
|
68
|
+
"karma": "^6.3.4",
|
|
69
69
|
"karma-chrome-launcher": "^3.1",
|
|
70
70
|
"karma-jasmine": "^4.0",
|
|
71
71
|
"karma-requirejs": "^1.1",
|
|
72
72
|
"merge2": "^1.4.1",
|
|
73
|
-
"mocha": "^
|
|
73
|
+
"mocha": "^9.0.2",
|
|
74
74
|
"mocha-lcov-reporter": "^1.2.0",
|
|
75
75
|
"nyc": "^15.1.0",
|
|
76
|
-
"prettier": "^2.
|
|
76
|
+
"prettier": "^2.3.2",
|
|
77
77
|
"requirejs": "^2.3.6",
|
|
78
|
-
"typedoc": "^0.
|
|
79
|
-
"typescript": "^4.
|
|
78
|
+
"typedoc": "^0.22.9",
|
|
79
|
+
"typescript": "^4.3.5"
|
|
80
80
|
}
|
|
81
81
|
}
|