Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tapraise/ibantools-germany

baumerdev16AGPL1.2402.2TypeScript support: included

IBAN Validator and Generator for German Bank Accounts

iban, sepa, bban, bank, account, validation, validator, generator, germany, kontonummer, bankleitzahl, pruefziffer, pruefzifferberechnungsmethode

readme

IBANTools-Germany: Validator and Generator for German Bank Accounts

CI: Lint, test and build Coverage Status

This TypeScript/JavaScript library validates IBAN and German bank account numbers. It can be used standalone or as an enhancement of IBAN validators, like IBANTools.

If you need German bank data in your project, e.g., to auto-fill forms when a user enters an IBAN, take a look at the side project BankData-Germany.

Version 1.2402.* includes data from 2024-06-03 to 2024-09-08, as well as from 2024-09-09 to 2024-12-08. Validation will be based on the data that is valid according to your system time (data changes at midnight CET on 2024-09-09).

Installation

Package Manager

Add it to your project using a package manager like npm or yarn. You should explicitly install the latest version, as the bank data may change multiple times a year.

$ npm install --save ibantools-germany@latest
# or
$ yarn add ibantools-germany@latest

Browser / CDN

If you only want the functions in your browser, you can include the following pre-built file.

<script src="https://cdn.jsdelivr.net/npm/ibantools-germany/dist/build/browser.js"></script>

Usage

The npm package contains the code for both ESM and CJS. Therefore, in addition to using import as shown in the usage examples below, you can also utilize require.

Validation

You can validate the bank account number and BLZ (Bankleitzahl = bank sort code), a BBAN, or an IBAN. Additionally, you have the option to restrict IBAN validation to only allow German IBANs.

import { isValidAccountNumberBLZ, isValidBBAN, isValidIBAN } from "ibantools-germany"

isValidAccountNumberBLZ("9290701", "10220500"); // true

isValidBBAN("102205000009290701"); // true
isValidBBAN("20041010050500013M02606"); // false (valid but not a German BBAN)

isValidIBAN("DE23102205000009290701"); // true
isValidIBAN("FR1420041010050500013M02606"); // true
isValidIBAN("FR1420041010050500013M02606", false); // false (only allow German IBAN)

Generation

import { generateBBAN, generateIBAN } from "ibantools-germany"

generateBBAN("9290701", "10220500"); // 102205000009290701
generateBBAN("foo", "bar"); // null

generateIBAN("9290701", "10220500"); // DE23102205000009290701
generateIBAN("foo", "bar"); // null

Browser / CDN

When using the pre-built version, the ibantoolsGermany object is globally defined on the window, containing the functions.

ibantoolsGermany.generateBBAN("9290701", "10220500");
ibantoolsGermany.generateIBAN("9290701", "10220500");
ibantoolsGermany.isValidAccountNumberBLZ("9290701", "10220500");
ibantoolsGermany.isValidBBAN("102205000009290701");
ibantoolsGermany.isValidIBAN("DE23102205000009290701");

Data Source

Unfortunately, there isn't a single algorithm to verify all German bank account numbers or BBANs, as each bank employs its own method(s) which can change periodically. To address this, Deutsche Bundesbank publishes updated data every quarter.

These updates can encompass both technical changes, such as modifications in check digit methods, as well as content changes like alterations to BLZ, bank names, and more. Some updates might not contain any relevant changes for this library at all.

Package Version

The version numbers are based on Semantic Versioning with some modifications.

1.2205.3

The first number represents the Major version. If this number increases, there may be updates that are not backward compatible, requiring adjustments to your code. In the above version string, the major version is 1.

The first two digits of the second number indicate the year of the included data and check digit methods. The third and fourth digits increase either with minor version changes that maintain backward compatibility or when new data is included. In the provided version string, the year is 2022, with a few minor updates, possibly including data updates for spring and summer.

The last number is reserved for patches and bug fixes.

Considering that the data could change up to four times a year, it's advisable to use an appropriate version string in your package.json. As breaking changes occur only when the first number changes, specifying something like "1.x" should suffice.

changelog

Changelog

2024-08-27 [v1.2402.2]

  • Fixed export order, default last ; #24

2024-08-20 [v1.2402.1]

  • Fixed method 27 ; #23

2024-08-11 [v1.2402.0]

  • Additionally includes data valid from 2024-09-09, removes data valid before 2024-06-03

2024-07-14 [v1.2401.2]

  • Fixed types exports ; #22

2024-06-28 [v1.2401.1]

  • Fixed method 73 ; #21
  • Upgraded dependencies, including braces (CVE-2024-37890) and ws (CVE-2024-37890)

2024-05-19 [v1.2401.0]

  • Additionally includes data valid from 2024-06-03, removes data valid before 2024-03-04

2024-02-17 [v1.2400.0]

  • Additionally includes data valid from 2024-03-04, removes data valid before 2023-12-04

2023-11-14 [v1.2303.0]

  • Additionally includes data valid from 2023-12-04, removes data valid before 2023-09-04

2023-10-18 [v1.2302.3]

  • Fixed method 85 ; #19
  • Fixed method 87

2023-10-18 [v1.2302.2]

  • Fixed method D6 ; #18
  • Updated dependencies (npm audit fix)

2023-09-22 [v1.2302.1]

  • Fixed method 51 ; #17

2023-08-20 [v1.2302.0]

  • Additionally includes data valid from 2023-09-04, removes data valid before 2023-06-05

2023-08-11 [v1.2301.5]

  • Internally removed TypeScript enums to improve compatibility with Angular ; see #15 and #16

2023-08-04 [v1.2301.4]

  • Fixed method A4 ; #14

2023-07-23 [v1.2301.3]

  • Upgraded dependencies, including word-wrap and tough-cookie (CVE-2023-26136)

2023-05-23 [v1.2301.2]

  • The Bundesbank informed that their data was inaccurate. Changes were made accordingly.

2023-05-14 [v1.2301.1]

  • Fix valid-from date from 2023-05-06 to 2023-06-05

2023-05-13 [v1.2301.0]

  • Additionally includes data valid from 2023-06-05, removes data valid before 2023-03-06

2023-05-13 [v1.2300.1]

  • Upgraded dependencies, including yaml (CVE-2023-2251)

2023-02-14 [v1.2300.0]

  • Additionally includes data valid from 2023-03-06, removes data valid before 2022-12-05

2023-02-14 [v1.2201.2]

  • Upgraded dependencies, including http-cache-semantics (CVE-2022-25881) and cacheable-request (GHSA-8x6c-cv3v-vp6g)

2023-01-17 [v1.2201.1]

  • Fixed failing test for current/next BLZs
  • Upgraded dependencies, including (CVE-2022-46175)

2022-11-13 [v1.2201.0]

  • Additionally includes data valid from 2022-12-05

2022-10-31 [v1.2200.6]

  • Fixed methods C0 ; #7
  • Fixed methods 85 ; #9
  • Fixed methods 53 ; #11
  • Updated method 61: An inaccurate method definition in the Bundesbank document may have resulted in false negatives in specific cases ; #13

2022-10-30 [v1.2200.2]

  • Fixed method 84 ; #3
  • Fixed method 16 ; #5

2022-10-29

  • Fixed typo ; #1

2022-10-26 [v1.2200.0]

  • First release