Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ibantools

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ibantools - npm Package Compare versions

Comparing version 4.2.2 to 4.3.0

46

build/ibantools.d.ts

@@ -7,6 +7,12 @@ /*!

/**
* Interface for validation options
*/
export interface ValidateIBANOptions {
allowQRIBAN: boolean;
}
/**
* Validate IBAN
* ```
* // returns true
* ibantools.isValidIBAN("NL91ABNA0517164300");
* ibantools.isValidIBAN("NL91ABNA0417164300");
* ```

@@ -17,4 +23,12 @@ * ```

* ```
* ```
* // returns true
* ibantools.isValidIBAN('CH4431999123000889012');
* ```
* ```
* // returns false
* ibantools.isValidIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
export declare function isValidIBAN(iban: string): boolean;
export declare function isValidIBAN(iban: string, validationOptions?: ValidateIBANOptions): boolean;
/**

@@ -30,3 +44,4 @@ * IBAM validation errors

WrongIBANChecksum = 5,
WrongAccountBankBranchChecksum = 6
WrongAccountBankBranchChecksum = 6,
QRIBANNotAllowed = 7
}

@@ -46,4 +61,13 @@ /**

* ```
* ```
* ```
* // returns {errorCodes: [], valid: true}
* ibantools.validateIBAN('CH4431999123000889012');
* ```
* ```
* // returns {errorCodes: [7], valid: false}
* ibantools.validateIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
export declare function validateIBAN(iban?: string): ValidateIBANResult;
export declare function validateIBAN(iban?: string, validationOptions?: ValidateIBANOptions): ValidateIBANResult;
/**

@@ -54,3 +78,3 @@ * Validate BBAN

* // returns true
* ibantools.isValidBBAN("ABNA0517164300", "NL");
* ibantools.isValidBBAN("ABNA0417164300", "NL");
* ```

@@ -76,2 +100,14 @@ * ```

/**
* Check if IBAN is QR-IBAN
* ```
* // returns true
* ibantools.isQRIBAN("CH4431999123000889012");
* ```
* ```
* // returns false
* ibantools.isQRIBAN("NL92ABNA0517164300");
* ```
*/
export declare function isQRIBAN(iban: string): boolean;
/**
* Interface for ComposeIBAN parameteres

@@ -78,0 +114,0 @@ */

@@ -11,3 +11,3 @@ /*!

* @module ibantools
* @version 4.2.2
* @version 4.3.0
* @license MPL-2.0

@@ -18,3 +18,3 @@ * @preferred

Object.defineProperty(exports, "__esModule", { value: true });
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;
exports.countrySpecs = exports.setCountryBBANValidation = exports.extractBIC = exports.validateBIC = exports.ValidationErrorsBIC = exports.isValidBIC = exports.getCountrySpecifications = exports.friendlyFormatIBAN = exports.electronicFormatIBAN = exports.extractIBAN = exports.composeIBAN = exports.isQRIBAN = exports.isSEPACountry = exports.isValidBBAN = exports.validateIBAN = exports.ValidationErrorsIBAN = exports.isValidIBAN = void 0;
/**

@@ -24,3 +24,3 @@ * Validate IBAN

* // returns true
* ibantools.isValidIBAN("NL91ABNA0517164300");
* ibantools.isValidIBAN("NL91ABNA0417164300");
* ```

@@ -31,8 +31,18 @@ * ```

* ```
* ```
* // returns true
* ibantools.isValidIBAN('CH4431999123000889012');
* ```
* ```
* // returns false
* ibantools.isValidIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
function isValidIBAN(iban) {
function isValidIBAN(iban, validationOptions) {
if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
if (iban === undefined || iban === null)
return false;
var reg = new RegExp('^[0-9]{2}$', '');
var spec = exports.countrySpecs[iban.slice(0, 2)];
var countryCode = iban.slice(0, 2);
var spec = exports.countrySpecs[countryCode];
if (spec === undefined || spec.bban_regexp === undefined || spec.bban_regexp === null || spec.chars === undefined)

@@ -42,4 +52,5 @@ return false;

reg.test(iban.slice(2, 4)) &&
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
isValidIBANChecksum(iban));
isValidBBAN(iban.slice(4), countryCode) &&
isValidIBANChecksum(iban) &&
(validationOptions.allowQRIBAN || !isQRIBAN(iban)));
}

@@ -59,2 +70,3 @@ exports.isValidIBAN = isValidIBAN;

ValidationErrorsIBAN[ValidationErrorsIBAN["WrongAccountBankBranchChecksum"] = 6] = "WrongAccountBankBranchChecksum";
ValidationErrorsIBAN[ValidationErrorsIBAN["QRIBANNotAllowed"] = 7] = "QRIBANNotAllowed";
})(ValidationErrorsIBAN = exports.ValidationErrorsIBAN || (exports.ValidationErrorsIBAN = {}));

@@ -67,4 +79,14 @@ /**

* ```
* ```
* ```
* // returns {errorCodes: [], valid: true}
* ibantools.validateIBAN('CH4431999123000889012');
* ```
* ```
* // returns {errorCodes: [7], valid: false}
* ibantools.validateIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
function validateIBAN(iban) {
function validateIBAN(iban, validationOptions) {
if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
var result = { errorCodes: [], valid: true };

@@ -99,2 +121,6 @@ if (iban !== undefined && iban !== null && iban !== '') {

}
if (!validationOptions.allowQRIBAN && isQRIBAN(iban)) {
result.valid = false;
result.errorCodes.push(ValidationErrorsIBAN.QRIBANNotAllowed);
}
}

@@ -113,3 +139,3 @@ else {

* // returns true
* ibantools.isValidBBAN("ABNA0517164300", "NL");
* ibantools.isValidBBAN("ABNA0417164300", "NL");
* ```

@@ -163,2 +189,24 @@ * ```

/**
* Check if IBAN is QR-IBAN
* ```
* // returns true
* ibantools.isQRIBAN("CH4431999123000889012");
* ```
* ```
* // returns false
* ibantools.isQRIBAN("NL92ABNA0517164300");
* ```
*/
function isQRIBAN(iban) {
if (iban === undefined || iban === null)
return false;
var countryCode = iban.slice(0, 2);
var QRIBANCountries = ['LX', 'CH'];
if (!QRIBANCountries.includes(countryCode))
return false;
var reg = new RegExp('^3[0-1]{1}[0-9]{3}$', '');
return reg.test(iban.slice(4, 9));
}
exports.isQRIBAN = isQRIBAN;
/**
* composeIBAN

@@ -165,0 +213,0 @@ *

@@ -11,3 +11,3 @@ /*!

* @module ibantools
* @version 4.2.2
* @version 4.3.0
* @license MPL-2.0

@@ -21,3 +21,3 @@ * @preferred

* // returns true
* ibantools.isValidIBAN("NL91ABNA0517164300");
* ibantools.isValidIBAN("NL91ABNA0417164300");
* ```

@@ -28,8 +28,18 @@ * ```

* ```
* ```
* // returns true
* ibantools.isValidIBAN('CH4431999123000889012');
* ```
* ```
* // returns false
* ibantools.isValidIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
export function isValidIBAN(iban) {
export function isValidIBAN(iban, validationOptions) {
if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
if (iban === undefined || iban === null)
return false;
var reg = new RegExp('^[0-9]{2}$', '');
var spec = countrySpecs[iban.slice(0, 2)];
var countryCode = iban.slice(0, 2);
var spec = countrySpecs[countryCode];
if (spec === undefined || spec.bban_regexp === undefined || spec.bban_regexp === null || spec.chars === undefined)

@@ -39,4 +49,5 @@ return false;

reg.test(iban.slice(2, 4)) &&
isValidBBAN(iban.slice(4), iban.slice(0, 2)) &&
isValidIBANChecksum(iban));
isValidBBAN(iban.slice(4), countryCode) &&
isValidIBANChecksum(iban) &&
(validationOptions.allowQRIBAN || !isQRIBAN(iban)));
}

@@ -55,2 +66,3 @@ /**

ValidationErrorsIBAN[ValidationErrorsIBAN["WrongAccountBankBranchChecksum"] = 6] = "WrongAccountBankBranchChecksum";
ValidationErrorsIBAN[ValidationErrorsIBAN["QRIBANNotAllowed"] = 7] = "QRIBANNotAllowed";
})(ValidationErrorsIBAN || (ValidationErrorsIBAN = {}));

@@ -63,4 +75,14 @@ /**

* ```
* ```
* ```
* // returns {errorCodes: [], valid: true}
* ibantools.validateIBAN('CH4431999123000889012');
* ```
* ```
* // returns {errorCodes: [7], valid: false}
* ibantools.validateIBAN('CH4431999123000889012', { allowQRIBAN: false });
* ```
*/
export function validateIBAN(iban) {
export function validateIBAN(iban, validationOptions) {
if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
var result = { errorCodes: [], valid: true };

@@ -95,2 +117,6 @@ if (iban !== undefined && iban !== null && iban !== '') {

}
if (!validationOptions.allowQRIBAN && isQRIBAN(iban)) {
result.valid = false;
result.errorCodes.push(ValidationErrorsIBAN.QRIBANNotAllowed);
}
}

@@ -108,3 +134,3 @@ else {

* // returns true
* ibantools.isValidBBAN("ABNA0517164300", "NL");
* ibantools.isValidBBAN("ABNA0417164300", "NL");
* ```

@@ -156,2 +182,23 @@ * ```

/**
* Check if IBAN is QR-IBAN
* ```
* // returns true
* ibantools.isQRIBAN("CH4431999123000889012");
* ```
* ```
* // returns false
* ibantools.isQRIBAN("NL92ABNA0517164300");
* ```
*/
export function isQRIBAN(iban) {
if (iban === undefined || iban === null)
return false;
var countryCode = iban.slice(0, 2);
var QRIBANCountries = ['LX', 'CH'];
if (!QRIBANCountries.includes(countryCode))
return false;
var reg = new RegExp('^3[0-1]{1}[0-9]{3}$', '');
return reg.test(iban.slice(4, 9));
}
/**
* composeIBAN

@@ -158,0 +205,0 @@ *

29

package.json
{
"name": "ibantools",
"version": "4.2.2",
"version": "4.3.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",

@@ -39,9 +39,13 @@ "keywords": [

"scripts": {
"build": "rm -rf dist && rm -rf jsnext && rm -rf build && gulp all",
"test": "gulp test-it",
"karma": "gulp karma",
"coverage": "gulp coverage",
"lint": "gulp lint",
"prepare": "npm run build",
"docs": "gulp docs"
"build": "npm run build-node && npm run build-bower && npm run build-module",
"build-node": "rm -rf build && npx tsc src/*.ts --declaration --target es5 --module commonjs --outDir ./build/",
"build-bower": "rm -rf dist && npx tsc src/*.ts --declaration --target es5 --module amd --outDir ./dist/",
"build-module": "rm -rf jsnext && npx tsc src/*.ts --target es5 --module es2015 --outDir ./jsnext/",
"test": "npm run build && mocha 'test/**/*.js'",
"karma": "karma start --single-run",
"coverage": "nyc mocha && nyc report --reporter=text-lcov | coveralls",
"lint": "eslint 'src/**/*.ts' 'test/**/*.js'",
"prepare": "npm run build-node",
"docs": "typedoc src/ibantools.ts",
"all": "npm run test && npm run lint && npm run karma && npm run docs"
},

@@ -62,6 +66,2 @@ "author": {

"eslint-plugin-prettier": "^4.0.0",
"gulp": "^4.0.2",
"gulp-rename": "^2.0",
"gulp-shell": "^0.8.0",
"gulp-typescript": "^5.0",
"jasmine-core": "^4.0.0",

@@ -72,3 +72,2 @@ "karma": "^6.3.4",

"karma-requirejs": "^1.1",
"merge2": "^1.4.1",
"mocha": "^10.0.0",

@@ -79,4 +78,4 @@ "mocha-lcov-reporter": "^1.2.0",

"requirejs": "^2.3.6",
"typedoc": "^0.23.1",
"typescript": "^4.3.5"
"typedoc": "^0.24.1",
"typescript": "^5.0.2"
},

@@ -83,0 +82,0 @@ "resolutions": {

@@ -55,3 +55,3 @@ # IBANTools

const ibantools = require('ibantools');
const iban = electronicFormatIBAN('NL91 ABNA 0517 1643 00'); // 'NL91ABNA0517164300'
const iban = electronicFormatIBAN('NL91 ABNA 0417 1643 00'); // 'NL91ABNA0517164300'
ibantools.isValidIBAN(iban);

@@ -71,3 +71,3 @@

require(["ibantools"], function(ibantools) {
console.log(ibantools.isValidIBAN('NL91 ABNA 0517 1643 00'));
console.log(ibantools.isValidIBAN('NL91 ABNA 0417 1643 00'));
console.log(ibantools.isValidBIC('ABNANL2A'));

@@ -74,0 +74,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc