ibantools

Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff
Source:
Version:
  • 2.0.0
Author:
  • Saša Jovanić
License:
  • MPL-2.0
See:

Methods

(static) composeIBAN(Object)

Source:
composeIBAN
Example
// returns NL91ABNA0417164300
ibantools.composeIBAN("NL", "ABNA0417164300");
Parameters:
Name Type Description
Object ComposeIBANParams {bban: string, countryCode: string}

(static) electronicFormatIBAN(IBAN) → {string}

Source:
Get IBAN in electronic format (no spaces) IBAN validation is not performed.
Example
// returns "NL91ABNA0417164300"
ibantools.electronicFormatIBAN("NL91 ABNA 0417 1643 00");
Parameters:
Name Type Description
IBAN string IBAN
Returns:
IBAN Electronic formated IBAN
Type
string

(static) extractBIC(BIC) → {ExtractBICResult}

Source:
extractBIC
Example
// returns {bankCode: "ABNA", countryCode: "NL", countryName: "Netherlands", locationCode: "2A", branchCode: null, testBIC: flase, valid: true}
ibantools.extractBIC("ABNANL2A");
Parameters:
Name Type Description
BIC string BIC
Returns:
Object {bancCode: string, countryCode: string, countryName: string, locationCode: string, branchCode: string, testBIC: boolean, valid: boolean}
Type
ExtractBICResult

(static) extractIBAN(IBAN) → {ExtractIBANResult}

Source:
extractIBAN
Example
// returns {iban: "NL91ABNA0417164300", bban: "ABNA0417164300", countryCode: "NL", countryName: "Netherlands", valid: true}
ibantools.extractIBAN("NL91 ABNA 0417 1643 00");
Parameters:
Name Type Description
IBAN string IBAN
Returns:
Object {iban: string, bban: string, countryCode: string, countryName: string, valid: boolean}
Type
ExtractIBANResult

(static) friendlyFormatIBAN(IBAN, separator) → {string}

Source:
Get IBAN in friendly format (separated after every 4 characters) IBAN validation is not performed.
Examples
// returns "NL91 ABNA 0417 1643 00"
ibantools.friendlyFormatIBAN("NL91ABNA0417164300");
// returns "NL91-ABNA-0417-1643-00"
ibantools.friendlyFormatIBAN("NL91ABNA0417164300","-");
Parameters:
Name Type Description
IBAN string IBAN
separator string Not required. Default separator is space " "
Returns:
IBAN Friendly formated IBAN
Type
string

(static) getCountrySpecifications() → {CountryMap}

Source:
getCountrySpecifications Returns specifications for all countries, even those who are not members of IBAN registry. `IBANRegistry` field indicates if country is member of not.
Example
// Validating IBAN form field after user selects his country
// <select id="countries">
//   ...
//   <option value="NL">Netherlands</option>
//   ...
// </select>
$("#countries").select(function() {
  // Find country
  let country = ibantools.getCountrySpecifications()[$(this).val()];
  // Add country code letters to IBAN form field
  $("input#iban").value($(this).val());
  // Add new value to "pattern" attribute to #iban input text field
  $("input#iban").attr("pattern", $(this).val() + "[0-9]{2}" + country.bban_regexp.slice(1).replace("$",""));
});
Returns:
Object [countryCode: string]CountrySpec -> {chars: :number, bban_regexp: string, name: string, IBANRegistry: boolean}
Type
CountryMap

(static) isValidBBAN(BBAN, countryCode) → {boolean}

Source:
Validate BBAN
Examples
// returns true
ibantools.isValidBBAN("ABNA0517164300", "NL");
// returns false
ibantools.isValidBBAN("A7NA0517164300", "NL");
Parameters:
Name Type Description
BBAN string BBAN
countryCode string Country code
Returns:
valid
Type
boolean

(static) isValidBIC(BIC) → {boolean}

Source:
Validate BIC/SWIFT
Examples
// returns true
ibantools.isValidBIC("ABNANL2A");
// returns true
ibantools.isValidBIC("NEDSZAJJXXX");
// returns false
ibantools.isValidBIC("ABN4NL2A");
// returns false
ibantools.isValidBIC("ABNA NL 2A");
Parameters:
Name Type Description
BIC string BIC
Returns:
valid
Type
boolean

(static) isValidIBAN(IBAN) → {boolean}

Source:
Validate IBAN
Examples
// returns true
ibantools.isValidIBAN("NL91ABNA0517164300");
// returns false
ibantools.isValidIBAN("NL92ABNA0517164300");
Parameters:
Name Type Description
IBAN string IBAN
Returns:
valid
Type
boolean