ibantools 4.1.5 → 4.2.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/README.md +12 -0
- package/build/ibantools.d.ts +11 -2
- package/build/ibantools.js +31 -8
- package/jsnext/ibantools.js +29 -7
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -86,6 +86,18 @@ If you are using tools that support `jsnext`, like a [rollup](https://github.com
|
|
|
86
86
|
|
|
87
87
|
Install library/module using npm. Package bundles type definitions and if you are on TypeScript 2.0 or above `tsc` will access those automatically. If not, check your `tsconfig.json` file.
|
|
88
88
|
|
|
89
|
+
### Extension
|
|
90
|
+
|
|
91
|
+
Country specifications can be extended with national BBAN validations by calling `setCountryBBANValidation`.
|
|
92
|
+
|
|
93
|
+
For example, to fully syntactically check German IBAN, you can install [IBANTools-Germany](https://github.com/baumerdev/ibantools-germany) and add this with
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
const ibantools = require('ibantools');
|
|
97
|
+
const ibantoolsGermany = require("ibantools-germany");
|
|
98
|
+
ibantools.setCountryBBANValidation("DE", ibantoolsGermany.isValidBBAN);
|
|
99
|
+
```
|
|
100
|
+
|
|
89
101
|
## Contributing
|
|
90
102
|
|
|
91
103
|
This project adheres to the Contributor Covenant [code of conduct](https://github.com/Simplify/ibantools/blob/master/.github/CODE_OF_CONDUCT.md).
|
package/build/ibantools.d.ts
CHANGED
|
@@ -195,8 +195,8 @@ export interface ExtractBICResult {
|
|
|
195
195
|
bankCode?: string;
|
|
196
196
|
countryCode?: string;
|
|
197
197
|
locationCode?: string;
|
|
198
|
-
branchCode
|
|
199
|
-
testBIC
|
|
198
|
+
branchCode: string | null;
|
|
199
|
+
testBIC: boolean;
|
|
200
200
|
valid: boolean;
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
@@ -224,6 +224,8 @@ export interface CountryMap {
|
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* Interface for IBAN Country Specification
|
|
227
|
+
*
|
|
228
|
+
* @ignore
|
|
227
229
|
*/
|
|
228
230
|
interface CountrySpecInternal {
|
|
229
231
|
chars?: number;
|
|
@@ -238,6 +240,13 @@ interface CountrySpecInternal {
|
|
|
238
240
|
interface CountryMapInternal {
|
|
239
241
|
[code: string]: CountrySpecInternal;
|
|
240
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Set custom BBAN validation function for country.
|
|
245
|
+
*
|
|
246
|
+
* If `bban_validation_func` already exists for the corresponding country,
|
|
247
|
+
* it will be overwritten.
|
|
248
|
+
*/
|
|
249
|
+
export declare const setCountryBBANValidation: (country: string, func: (bban: string) => boolean) => boolean;
|
|
241
250
|
/**
|
|
242
251
|
* Country specifications
|
|
243
252
|
*/
|
package/build/ibantools.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* @package Documentation
|
|
9
9
|
* @author Saša Jovanić
|
|
10
10
|
* @module ibantools
|
|
11
|
-
* @version 4.
|
|
11
|
+
* @version 4.2.0
|
|
12
12
|
* @license MPL-2.0
|
|
13
13
|
* @preferred
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.countrySpecs = exports.extractBIC = exports.validateBIC = exports.ValidationErrorsBIC = exports.isValidBIC = exports.getCountrySpecifications = exports.friendlyFormatIBAN = exports.electronicFormatIBAN = exports.extractIBAN = exports.composeIBAN = exports.isSEPACountry = exports.isValidBBAN = exports.validateIBAN = exports.ValidationErrorsIBAN = exports.isValidIBAN = void 0;
|
|
17
|
+
exports.countrySpecs = exports.setCountryBBANValidation = exports.extractBIC = exports.validateBIC = exports.ValidationErrorsBIC = exports.isValidBIC = exports.getCountrySpecifications = exports.friendlyFormatIBAN = exports.electronicFormatIBAN = exports.extractIBAN = exports.composeIBAN = exports.isSEPACountry = exports.isValidBBAN = exports.validateIBAN = exports.ValidationErrorsIBAN = exports.isValidIBAN = void 0;
|
|
18
18
|
/**
|
|
19
19
|
* Validate IBAN
|
|
20
20
|
* ```
|
|
@@ -424,7 +424,7 @@ function extractBIC(inputBic) {
|
|
|
424
424
|
result.countryCode = bic.slice(4, 6);
|
|
425
425
|
result.locationCode = bic.slice(6, 8);
|
|
426
426
|
result.testBIC = result.locationCode[1] === '0' ? true : false;
|
|
427
|
-
result.branchCode = bic.length > 8 ? bic.slice(8) :
|
|
427
|
+
result.branchCode = bic.length > 8 ? bic.slice(8) : null;
|
|
428
428
|
result.valid = true;
|
|
429
429
|
}
|
|
430
430
|
else {
|
|
@@ -567,11 +567,11 @@ var checkCroatianBBAN = function (bban) {
|
|
|
567
567
|
return checkMod1110(bankBranch, controlBankBranch) && checkMod1110(account, controlAccount);
|
|
568
568
|
};
|
|
569
569
|
/**
|
|
570
|
-
* Czech (CZ) BBAN check
|
|
570
|
+
* Czech (CZ) and Slowak (SK) BBAN check
|
|
571
571
|
*
|
|
572
572
|
* @ignore
|
|
573
573
|
*/
|
|
574
|
-
var
|
|
574
|
+
var checkCzechAndSlovakBBAN = function (bban) {
|
|
575
575
|
var weightsPrefix = [10, 5, 8, 4, 2, 1];
|
|
576
576
|
var weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
|
|
577
577
|
var controlPrefix = parseInt(bban.charAt(9), 10);
|
|
@@ -744,6 +744,20 @@ var checkHungarianBBAN = function (bban) {
|
|
|
744
744
|
return controlDigitAccount === (remainder_2 === 0 ? 0 : 10 - remainder_2);
|
|
745
745
|
}
|
|
746
746
|
};
|
|
747
|
+
/**
|
|
748
|
+
* Set custom BBAN validation function for country.
|
|
749
|
+
*
|
|
750
|
+
* If `bban_validation_func` already exists for the corresponding country,
|
|
751
|
+
* it will be overwritten.
|
|
752
|
+
*/
|
|
753
|
+
var setCountryBBANValidation = function (country, func) {
|
|
754
|
+
if (typeof exports.countrySpecs[country] === 'undefined') {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
exports.countrySpecs[country].bban_validation_func = func;
|
|
758
|
+
return true;
|
|
759
|
+
};
|
|
760
|
+
exports.setCountryBBANValidation = setCountryBBANValidation;
|
|
747
761
|
/**
|
|
748
762
|
* Country specifications
|
|
749
763
|
*/
|
|
@@ -892,7 +906,7 @@ exports.countrySpecs = {
|
|
|
892
906
|
CZ: {
|
|
893
907
|
chars: 24,
|
|
894
908
|
bban_regexp: '^[0-9]{20}$',
|
|
895
|
-
bban_validation_func:
|
|
909
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
896
910
|
IBANRegistry: true,
|
|
897
911
|
SEPA: true,
|
|
898
912
|
},
|
|
@@ -1171,7 +1185,10 @@ exports.countrySpecs = {
|
|
|
1171
1185
|
bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
|
|
1172
1186
|
},
|
|
1173
1187
|
MM: {},
|
|
1174
|
-
MN: {
|
|
1188
|
+
MN: {
|
|
1189
|
+
chars: 20,
|
|
1190
|
+
bban_regexp: '^[0-9]{16}$',
|
|
1191
|
+
},
|
|
1175
1192
|
MO: {},
|
|
1176
1193
|
MP: {},
|
|
1177
1194
|
MQ: {
|
|
@@ -1315,7 +1332,13 @@ exports.countrySpecs = {
|
|
|
1315
1332
|
SEPA: true,
|
|
1316
1333
|
},
|
|
1317
1334
|
SJ: {},
|
|
1318
|
-
SK: {
|
|
1335
|
+
SK: {
|
|
1336
|
+
chars: 24,
|
|
1337
|
+
bban_regexp: '^[0-9]{20}$',
|
|
1338
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
1339
|
+
IBANRegistry: true,
|
|
1340
|
+
SEPA: true,
|
|
1341
|
+
},
|
|
1319
1342
|
SL: {},
|
|
1320
1343
|
SM: {
|
|
1321
1344
|
chars: 27,
|
package/jsnext/ibantools.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @package Documentation
|
|
9
9
|
* @author Saša Jovanić
|
|
10
10
|
* @module ibantools
|
|
11
|
-
* @version 4.
|
|
11
|
+
* @version 4.2.0
|
|
12
12
|
* @license MPL-2.0
|
|
13
13
|
* @preferred
|
|
14
14
|
*/
|
|
@@ -411,7 +411,7 @@ export function extractBIC(inputBic) {
|
|
|
411
411
|
result.countryCode = bic.slice(4, 6);
|
|
412
412
|
result.locationCode = bic.slice(6, 8);
|
|
413
413
|
result.testBIC = result.locationCode[1] === '0' ? true : false;
|
|
414
|
-
result.branchCode = bic.length > 8 ? bic.slice(8) :
|
|
414
|
+
result.branchCode = bic.length > 8 ? bic.slice(8) : null;
|
|
415
415
|
result.valid = true;
|
|
416
416
|
}
|
|
417
417
|
else {
|
|
@@ -553,11 +553,11 @@ var checkCroatianBBAN = function (bban) {
|
|
|
553
553
|
return checkMod1110(bankBranch, controlBankBranch) && checkMod1110(account, controlAccount);
|
|
554
554
|
};
|
|
555
555
|
/**
|
|
556
|
-
* Czech (CZ) BBAN check
|
|
556
|
+
* Czech (CZ) and Slowak (SK) BBAN check
|
|
557
557
|
*
|
|
558
558
|
* @ignore
|
|
559
559
|
*/
|
|
560
|
-
var
|
|
560
|
+
var checkCzechAndSlovakBBAN = function (bban) {
|
|
561
561
|
var weightsPrefix = [10, 5, 8, 4, 2, 1];
|
|
562
562
|
var weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
|
|
563
563
|
var controlPrefix = parseInt(bban.charAt(9), 10);
|
|
@@ -730,6 +730,19 @@ var checkHungarianBBAN = function (bban) {
|
|
|
730
730
|
return controlDigitAccount === (remainder_2 === 0 ? 0 : 10 - remainder_2);
|
|
731
731
|
}
|
|
732
732
|
};
|
|
733
|
+
/**
|
|
734
|
+
* Set custom BBAN validation function for country.
|
|
735
|
+
*
|
|
736
|
+
* If `bban_validation_func` already exists for the corresponding country,
|
|
737
|
+
* it will be overwritten.
|
|
738
|
+
*/
|
|
739
|
+
export var setCountryBBANValidation = function (country, func) {
|
|
740
|
+
if (typeof countrySpecs[country] === 'undefined') {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
countrySpecs[country].bban_validation_func = func;
|
|
744
|
+
return true;
|
|
745
|
+
};
|
|
733
746
|
/**
|
|
734
747
|
* Country specifications
|
|
735
748
|
*/
|
|
@@ -878,7 +891,7 @@ export var countrySpecs = {
|
|
|
878
891
|
CZ: {
|
|
879
892
|
chars: 24,
|
|
880
893
|
bban_regexp: '^[0-9]{20}$',
|
|
881
|
-
bban_validation_func:
|
|
894
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
882
895
|
IBANRegistry: true,
|
|
883
896
|
SEPA: true,
|
|
884
897
|
},
|
|
@@ -1157,7 +1170,10 @@ export var countrySpecs = {
|
|
|
1157
1170
|
bban_regexp: '^[A-Z0-9]{2}[0-9]{22}$',
|
|
1158
1171
|
},
|
|
1159
1172
|
MM: {},
|
|
1160
|
-
MN: {
|
|
1173
|
+
MN: {
|
|
1174
|
+
chars: 20,
|
|
1175
|
+
bban_regexp: '^[0-9]{16}$',
|
|
1176
|
+
},
|
|
1161
1177
|
MO: {},
|
|
1162
1178
|
MP: {},
|
|
1163
1179
|
MQ: {
|
|
@@ -1301,7 +1317,13 @@ export var countrySpecs = {
|
|
|
1301
1317
|
SEPA: true,
|
|
1302
1318
|
},
|
|
1303
1319
|
SJ: {},
|
|
1304
|
-
SK: {
|
|
1320
|
+
SK: {
|
|
1321
|
+
chars: 24,
|
|
1322
|
+
bban_regexp: '^[0-9]{20}$',
|
|
1323
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
1324
|
+
IBANRegistry: true,
|
|
1325
|
+
SEPA: true,
|
|
1326
|
+
},
|
|
1305
1327
|
SL: {},
|
|
1306
1328
|
SM: {
|
|
1307
1329
|
chars: 27,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ibantools",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.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,12 +50,12 @@
|
|
|
50
50
|
},
|
|
51
51
|
"license": "MPL-2.0",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
54
|
-
"@typescript-eslint/parser": "^
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
55
55
|
"chai": "^4.3.4",
|
|
56
56
|
"coveralls": "^3.1.1",
|
|
57
57
|
"docdash": "^1.2.0",
|
|
58
|
-
"eslint": "^
|
|
58
|
+
"eslint": "^8.0.0",
|
|
59
59
|
"eslint-config-prettier": "^8.3.0",
|
|
60
60
|
"eslint-plugin-prettier": "^4.0.0",
|
|
61
61
|
"gulp": "^4.0.2",
|
|
@@ -65,15 +65,18 @@
|
|
|
65
65
|
"jasmine-core": "^4.0.0",
|
|
66
66
|
"karma": "^6.3.4",
|
|
67
67
|
"karma-chrome-launcher": "^3.1",
|
|
68
|
-
"karma-jasmine": "^
|
|
68
|
+
"karma-jasmine": "^5.0",
|
|
69
69
|
"karma-requirejs": "^1.1",
|
|
70
70
|
"merge2": "^1.4.1",
|
|
71
|
-
"mocha": "^
|
|
71
|
+
"mocha": "^10.0.0",
|
|
72
72
|
"mocha-lcov-reporter": "^1.2.0",
|
|
73
73
|
"nyc": "^15.1.0",
|
|
74
74
|
"prettier": "^2.3.2",
|
|
75
75
|
"requirejs": "^2.3.6",
|
|
76
|
-
"typedoc": "^0.
|
|
76
|
+
"typedoc": "^0.23.1",
|
|
77
77
|
"typescript": "^4.3.5"
|
|
78
|
+
},
|
|
79
|
+
"resolutions": {
|
|
80
|
+
"source-map": "^0.8.0-beta.0"
|
|
78
81
|
}
|
|
79
82
|
}
|