Comparing version 4.1.6 to 4.2.0
@@ -227,2 +227,4 @@ /*! | ||
* Interface for IBAN Country Specification | ||
* | ||
* @ignore | ||
*/ | ||
@@ -243,2 +245,9 @@ interface CountrySpecInternal { | ||
/** | ||
* Set custom BBAN validation function for country. | ||
* | ||
* If `bban_validation_func` already exists for the corresponding country, | ||
* it will be overwritten. | ||
*/ | ||
export declare const setCountryBBANValidation: (country: string, func: (bban: string) => boolean) => boolean; | ||
/** | ||
* Country specifications | ||
@@ -245,0 +254,0 @@ */ |
@@ -11,3 +11,3 @@ /*! | ||
* @module ibantools | ||
* @version 4.1.6 | ||
* @version 4.2.0 | ||
* @license MPL-2.0 | ||
@@ -18,3 +18,3 @@ * @preferred | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
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; | ||
/** | ||
@@ -572,7 +572,7 @@ * Validate IBAN | ||
/** | ||
* Czech (CZ) BBAN check | ||
* Czech (CZ) and Slowak (SK) BBAN check | ||
* | ||
* @ignore | ||
*/ | ||
var checkCzechBBAN = function (bban) { | ||
var checkCzechAndSlovakBBAN = function (bban) { | ||
var weightsPrefix = [10, 5, 8, 4, 2, 1]; | ||
@@ -751,2 +751,16 @@ var weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1]; | ||
/** | ||
* Set custom BBAN validation function for country. | ||
* | ||
* If `bban_validation_func` already exists for the corresponding country, | ||
* it will be overwritten. | ||
*/ | ||
var setCountryBBANValidation = function (country, func) { | ||
if (typeof exports.countrySpecs[country] === 'undefined') { | ||
return false; | ||
} | ||
exports.countrySpecs[country].bban_validation_func = func; | ||
return true; | ||
}; | ||
exports.setCountryBBANValidation = setCountryBBANValidation; | ||
/** | ||
* Country specifications | ||
@@ -899,3 +913,3 @@ */ | ||
bban_regexp: '^[0-9]{20}$', | ||
bban_validation_func: checkCzechBBAN, | ||
bban_validation_func: checkCzechAndSlovakBBAN, | ||
IBANRegistry: true, | ||
@@ -1326,3 +1340,9 @@ SEPA: true, | ||
SJ: {}, | ||
SK: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true }, | ||
SK: { | ||
chars: 24, | ||
bban_regexp: '^[0-9]{20}$', | ||
bban_validation_func: checkCzechAndSlovakBBAN, | ||
IBANRegistry: true, | ||
SEPA: true, | ||
}, | ||
SL: {}, | ||
@@ -1329,0 +1349,0 @@ SM: { |
@@ -11,3 +11,3 @@ /*! | ||
* @module ibantools | ||
* @version 4.1.6 | ||
* @version 4.2.0 | ||
* @license MPL-2.0 | ||
@@ -557,7 +557,7 @@ * @preferred | ||
/** | ||
* Czech (CZ) BBAN check | ||
* Czech (CZ) and Slowak (SK) BBAN check | ||
* | ||
* @ignore | ||
*/ | ||
var checkCzechBBAN = function (bban) { | ||
var checkCzechAndSlovakBBAN = function (bban) { | ||
var weightsPrefix = [10, 5, 8, 4, 2, 1]; | ||
@@ -736,2 +736,15 @@ var weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1]; | ||
/** | ||
* Set custom BBAN validation function for country. | ||
* | ||
* If `bban_validation_func` already exists for the corresponding country, | ||
* it will be overwritten. | ||
*/ | ||
export var setCountryBBANValidation = function (country, func) { | ||
if (typeof countrySpecs[country] === 'undefined') { | ||
return false; | ||
} | ||
countrySpecs[country].bban_validation_func = func; | ||
return true; | ||
}; | ||
/** | ||
* Country specifications | ||
@@ -884,3 +897,3 @@ */ | ||
bban_regexp: '^[0-9]{20}$', | ||
bban_validation_func: checkCzechBBAN, | ||
bban_validation_func: checkCzechAndSlovakBBAN, | ||
IBANRegistry: true, | ||
@@ -1311,3 +1324,9 @@ SEPA: true, | ||
SJ: {}, | ||
SK: { chars: 24, bban_regexp: '^[0-9]{20}$', IBANRegistry: true, SEPA: true }, | ||
SK: { | ||
chars: 24, | ||
bban_regexp: '^[0-9]{20}$', | ||
bban_validation_func: checkCzechAndSlovakBBAN, | ||
IBANRegistry: true, | ||
SEPA: true, | ||
}, | ||
SL: {}, | ||
@@ -1314,0 +1333,0 @@ SM: { |
{ | ||
"name": "ibantools", | ||
"version": "4.1.6", | ||
"version": "4.2.0", | ||
"description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff like ISO 3136-1 alpha 2 country list", | ||
@@ -53,8 +53,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.28.4", | ||
"@typescript-eslint/parser": "^4.28.4", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"chai": "^4.3.4", | ||
"coveralls": "^3.1.1", | ||
"docdash": "^1.2.0", | ||
"eslint": "^7.31.0", | ||
"eslint": "^8.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -61,0 +61,0 @@ "eslint-plugin-prettier": "^4.0.0", |
@@ -89,2 +89,14 @@ # IBANTools | ||
### Extension | ||
Country specifications can be extended with national BBAN validations by calling `setCountryBBANValidation`. | ||
For example, to fully syntactically check German IBAN, you can install [IBANTools-Germany](https://github.com/baumerdev/ibantools-germany) and add this with | ||
``` | ||
const ibantools = require('ibantools'); | ||
const ibantoolsGermany = require("ibantools-germany"); | ||
ibantools.setCountryBBANValidation("DE", ibantoolsGermany.isValidBBAN); | ||
``` | ||
## Contributing | ||
@@ -91,0 +103,0 @@ |
109322
3136
113