ibantools 4.1.6 → 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 +9 -0
- package/build/ibantools.js +26 -6
- package/jsnext/ibantools.js +24 -5
- package/package.json +4 -4
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
|
@@ -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
|
* ```
|
|
@@ -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
|
},
|
|
@@ -1318,7 +1332,13 @@ exports.countrySpecs = {
|
|
|
1318
1332
|
SEPA: true,
|
|
1319
1333
|
},
|
|
1320
1334
|
SJ: {},
|
|
1321
|
-
SK: {
|
|
1335
|
+
SK: {
|
|
1336
|
+
chars: 24,
|
|
1337
|
+
bban_regexp: '^[0-9]{20}$',
|
|
1338
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
1339
|
+
IBANRegistry: true,
|
|
1340
|
+
SEPA: true,
|
|
1341
|
+
},
|
|
1322
1342
|
SL: {},
|
|
1323
1343
|
SM: {
|
|
1324
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
|
*/
|
|
@@ -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
|
},
|
|
@@ -1304,7 +1317,13 @@ export var countrySpecs = {
|
|
|
1304
1317
|
SEPA: true,
|
|
1305
1318
|
},
|
|
1306
1319
|
SJ: {},
|
|
1307
|
-
SK: {
|
|
1320
|
+
SK: {
|
|
1321
|
+
chars: 24,
|
|
1322
|
+
bban_regexp: '^[0-9]{20}$',
|
|
1323
|
+
bban_validation_func: checkCzechAndSlovakBBAN,
|
|
1324
|
+
IBANRegistry: true,
|
|
1325
|
+
SEPA: true,
|
|
1326
|
+
},
|
|
1308
1327
|
SL: {},
|
|
1309
1328
|
SM: {
|
|
1310
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",
|