Comparing version 1.1.0 to 1.2.0
@@ -86,3 +86,3 @@ /*! | ||
* @param {string} IBAN IBAN | ||
* @result {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
* @return {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
*/ | ||
@@ -137,1 +137,41 @@ export declare function extractIBAN(iban: string): ExtractIBANResult; | ||
export declare function getCountrySpecifications(): CountryMap; | ||
/** | ||
* Validate BIC/SWIFT | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('ABNANL2A'); | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('NEDSZAJJXXX'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABN4NL2A'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABNA NL 2A'); | ||
* @alias module:ibantools.isValidBIC | ||
* @param {string} BIC BIC | ||
* @return {boolean} valid | ||
*/ | ||
export declare function isValidBIC(bic: string): boolean; | ||
/** | ||
* Interface for ExtractBIC result | ||
*/ | ||
export interface ExtractBICResult { | ||
bankCode?: string; | ||
countryCode?: string; | ||
locationCode?: string; | ||
branchCode?: string; | ||
testBIC?: boolean; | ||
valid: boolean; | ||
} | ||
/** | ||
* extractBIC | ||
* @example | ||
* // returns {bankCode: 'ABNA', countryCode: 'NL', locationCode: '2A', branchCode: null, testBIC: flase, valid: true} | ||
* ibantools.extractBIC('ABNANL2A'); | ||
* @alias module:ibantools.extractBIC | ||
* @param {string} BIC BIC | ||
* @return {ExtractBICResult} Object {bancCode: string, countryCode: string, locationCode: string, branchCode: string, testBIC: boolean, valid: boolean} | ||
*/ | ||
export declare function extractBIC(bic: string): ExtractBICResult; |
@@ -11,3 +11,3 @@ /*! | ||
* @see module:ibantools | ||
* @version 1.1.0 | ||
* @version 1.2.0 | ||
* @license MPL-2.0 | ||
@@ -106,3 +106,3 @@ */ | ||
* @param {string} IBAN IBAN | ||
* @result {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
* @return {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
*/ | ||
@@ -221,2 +221,50 @@ function extractIBAN(iban) { | ||
/** | ||
* Validate BIC/SWIFT | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('ABNANL2A'); | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('NEDSZAJJXXX'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABN4NL2A'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABNA NL 2A'); | ||
* @alias module:ibantools.isValidBIC | ||
* @param {string} BIC BIC | ||
* @return {boolean} valid | ||
*/ | ||
function isValidBIC(bic) { | ||
var reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}[XXX0-9]{0,3}$', ''); | ||
return reg.test(bic); | ||
} | ||
exports.isValidBIC = isValidBIC; | ||
/** | ||
* extractBIC | ||
* @example | ||
* // returns {bankCode: 'ABNA', countryCode: 'NL', locationCode: '2A', branchCode: null, testBIC: flase, valid: true} | ||
* ibantools.extractBIC('ABNANL2A'); | ||
* @alias module:ibantools.extractBIC | ||
* @param {string} BIC BIC | ||
* @return {ExtractBICResult} Object {bancCode: string, countryCode: string, locationCode: string, branchCode: string, testBIC: boolean, valid: boolean} | ||
*/ | ||
function extractBIC(bic) { | ||
var result = {}; | ||
if (isValidBIC(bic)) { | ||
result.bankCode = bic.slice(0, 4); | ||
result.countryCode = bic.slice(4, 6); | ||
result.locationCode = bic.slice(6, 8); | ||
result.testBIC = (result.locationCode[1] == '0' ? true : false); | ||
result.branchCode = (bic.length > 8 ? bic.slice(8) : null); | ||
result.valid = true; | ||
} | ||
else { | ||
result.valid = false; | ||
} | ||
return result; | ||
} | ||
exports.extractBIC = extractBIC; | ||
/** | ||
* Fill map of IBAN country specifications | ||
@@ -223,0 +271,0 @@ */ |
@@ -11,3 +11,3 @@ /*! | ||
* @see module:ibantools | ||
* @version 1.1.0 | ||
* @version 1.2.0 | ||
* @license MPL-2.0 | ||
@@ -103,3 +103,3 @@ */ | ||
* @param {string} IBAN IBAN | ||
* @result {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
* @return {ExtractIBANResult} Object {bban: string, countryCode: string, countryName: string, valid: boolean} | ||
*/ | ||
@@ -214,2 +214,48 @@ export function extractIBAN(iban) { | ||
/** | ||
* Validate BIC/SWIFT | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('ABNANL2A'); | ||
* @example | ||
* // returns true | ||
* ibantools.isValidBIC('NEDSZAJJXXX'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABN4NL2A'); | ||
* @example | ||
* // returns false | ||
* ibantools.isValidBIC('ABNA NL 2A'); | ||
* @alias module:ibantools.isValidBIC | ||
* @param {string} BIC BIC | ||
* @return {boolean} valid | ||
*/ | ||
export function isValidBIC(bic) { | ||
let reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}[XXX0-9]{0,3}$', ''); | ||
return reg.test(bic); | ||
} | ||
/** | ||
* extractBIC | ||
* @example | ||
* // returns {bankCode: 'ABNA', countryCode: 'NL', locationCode: '2A', branchCode: null, testBIC: flase, valid: true} | ||
* ibantools.extractBIC('ABNANL2A'); | ||
* @alias module:ibantools.extractBIC | ||
* @param {string} BIC BIC | ||
* @return {ExtractBICResult} Object {bancCode: string, countryCode: string, locationCode: string, branchCode: string, testBIC: boolean, valid: boolean} | ||
*/ | ||
export function extractBIC(bic) { | ||
let result = {}; | ||
if (isValidBIC(bic)) { | ||
result.bankCode = bic.slice(0, 4); | ||
result.countryCode = bic.slice(4, 6); | ||
result.locationCode = bic.slice(6, 8); | ||
result.testBIC = (result.locationCode[1] == '0' ? true : false); | ||
result.branchCode = (bic.length > 8 ? bic.slice(8) : null); | ||
result.valid = true; | ||
} | ||
else { | ||
result.valid = false; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Fill map of IBAN country specifications | ||
@@ -216,0 +262,0 @@ */ |
{ | ||
"name": "ibantools", | ||
"version": "1.1.0", | ||
"description": "Validation of IBAN numbers and generation of IBAN's plus some other helpful stuff", | ||
"version": "1.2.0", | ||
"description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff", | ||
"keywords": [ | ||
@@ -49,2 +49,3 @@ "IBAN", | ||
"cheerio": "^0.22", | ||
"coveralls": "^2.11.12", | ||
"gulp": "^3.9", | ||
@@ -54,18 +55,19 @@ "gulp-mocha": "^3.0", | ||
"gulp-shell": "^0.5", | ||
"gulp-typescript": "^2.9", | ||
"gulp-typescript": "^3.1", | ||
"istanbul": "^0.4", | ||
"jasmine-core": "^2.4", | ||
"jsdoc": "^3.4", | ||
"karma": "^1.2", | ||
"karma-chrome-launcher": "^2.0", | ||
"karma-jasmine": "^1.0", | ||
"karma-requirejs": "^1.0", | ||
"merge2": "^1.0", | ||
"mocha": "^3.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"request": "^2.67", | ||
"requirejs": "^2.1", | ||
"run-sequence": "^1.1", | ||
"typescript": "^1.8", | ||
"typings": "^1.3", | ||
"karma": "^1.2", | ||
"karma-chrome-launcher": "^2.0", | ||
"karma-jasmine": "^1.0", | ||
"karma-requirejs": "^1.0" | ||
"typescript": "^2.1", | ||
"typings": "^2.1" | ||
} | ||
} |
@@ -7,12 +7,17 @@ # IBANTools | ||
[![npm version](https://badge.fury.io/js/ibantools.svg)](https://badge.fury.io/js/ibantools) | ||
[![Build Status](https://travis-ci.org/Simplify/ibantools.svg?branch=master)](https://travis-ci.org/Simplify/ibantools) | ||
[![Coverage Status](https://coveralls.io/repos/github/Simplify/ibantools/badge.svg?branch=master)](https://coveralls.io/github/Simplify/ibantools?branch=master) | ||
[![devDependency Status](https://david-dm.org/simplify/ibantools/dev-status.svg)](https://david-dm.org/simplify/ibantools#info=devDependencies) | ||
[![Dependency Status](https://david-dm.org/simplify/ibantools.svg)](https://david-dm.org/simplify/ibantools) | ||
[![Dependency Status](https://dependencyci.com/github/Simplify/ibantools/badge)](https://dependencyci.com/github/Simplify/ibantools) | ||
[![Build Status](https://travis-ci.org/Simplify/ibantools.svg?branch=master)](https://travis-ci.org/Simplify/ibantools) | ||
IBANTools is TypeScript/JavaScript library for validation, creation and extraction of IBAN, BBAN and BIC/SWIFT numbers. | ||
IBANTools is JavaScript library for validation, creation and extraction of IBAN's. | ||
For more information about IBAN see [wikipedia page](https://en.wikipedia.org/wiki/International_Bank_Account_Number) and | ||
For more information about IBAN/BBAN see [wikipedia page](https://en.wikipedia.org/wiki/International_Bank_Account_Number) and | ||
[IBAN registry](https://www.swift.com/sites/default/files/resources/swift_standards_ibanregistry.pdf). | ||
For more information about BIC/SWIFT see [this wikipedia page](https://en.wikipedia.org/wiki/ISO_9362). | ||
## Installation and usage | ||
@@ -39,2 +44,3 @@ | ||
ibantools.isValidIBAN('NL91 ABNA 0517 1643 00'); | ||
ibantools.isValidBIC('ABNANL2A'); | ||
``` | ||
@@ -47,2 +53,3 @@ | ||
console.log(ibantools.isValidIBAN('NL91 ABNA 0517 1643 00')); | ||
console.log(ibantools.isValidBIC('ABNANL2A')); | ||
}); | ||
@@ -49,0 +56,0 @@ ``` |
{ | ||
"name": "ibantools", | ||
"globalDependencies": { | ||
"chai": "registry:dt/chai#3.4.0+20160601211834", | ||
"mocha": "registry:env/mocha#2.2.5+20160723033700", | ||
"chai": "registry:dt/chai#3.4.0+20160926213833", | ||
"mocha": "registry:dt/mocha#2.2.5+20170204022515", | ||
"node": "registry:env/node#6.0.0+20160825160117" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61774
892
86
23