Skip to content

IBAN

The Polish IBAN (International Bank Account Number) is the PL-prefixed form of the NRB. It is 28 characters long: the 2-letter country code PL followed by the 26-digit NRB.

import { Numerik } from '@slashlab/numerik-js'
// Boolean
Numerik.iban().isValid('PL61102010260000000000000000') // true
// Spaced format is accepted
Numerik.iban().isValid('PL61 1020 1026 0000 0000 0000 0000') // true
// Rich result
const result = Numerik.iban().validate('PL61102010260000000000000000')
result.isValid // true
// Parse to value object
const iban = Numerik.iban().parse('PL61102010260000000000000000')
// Null on failure instead of exception
const maybe = Numerik.iban().tryParse('bad-input') // null

parse() and tryParse() return an Iban instance.

MethodReturn typeDescription
getRaw()stringThe original input, untouched.
getNormalized()stringPL + 26 digits (spaces stripped).
toString()stringAlias for getNormalized().
MethodReturn typeDescription
getFormatted()stringHuman-readable IBAN: PLCC NNNN NNNN NNNN NNNN NNNN NNNN.
MethodReturn typeDescription
getCountryCode()stringAlways 'PL'.
getNrb()stringThe 26-digit NRB portion (without PL prefix).
getCheckDigits()stringCharacters 2–3 (2 digits after the country code) — MOD-97 check digits.
getSortCode()stringDigits 4–11 of the IBAN (8 digits) — bank sort code.
getBankCode()stringDigits 4–6 of the IBAN (3 digits) — bank identifier.
getAccountNumber()stringDigits 12–27 of the IBAN (16 digits) — customer account number.
const iban = Numerik.iban().parse('PL61102010260000000000000000')
iban.getRaw() // 'PL61102010260000000000000000'
iban.getNormalized() // 'PL61102010260000000000000000'
iban.getFormatted() // 'PL61 1020 1026 0000 0000 0000 0000'
iban.getCountryCode() // 'PL'
iban.getNrb() // '61102010260000000000000000'
iban.getCheckDigits() // '61'
iban.getSortCode() // '10201026'
iban.getBankCode() // '102'
iban.getAccountNumber() // '0000000000000000'
ReasonValueWhen
InvalidLengthinvalid_lengthInput is not exactly 28 characters (2 + 26 digits) after normalisation.
InvalidCharactersinvalid_charactersCharacters other than PL, digits, and spaces are present.
InvalidFormatinvalid_formatMissing or incorrect PL country prefix.
InvalidChecksuminvalid_checksumMOD-97 check digit does not match.

Uses the MOD-97 algorithm from ISO 13616:

  1. Reject inputs longer than 40 characters. Strip spaces and hyphens. Assert the PL prefix is present.
  2. Assert exactly 28 characters remain (PL + 26 digits).
  3. Rearrange: move the first 4 characters (PL + 2 check digits) to the end and replace the country code with its numeric equivalent (PL = 2521), giving a 30-digit string.
  4. Compute the 30-digit string modulo 97. The result must equal 1.

See Algorithms for the full NRB MOD-97 reference.

  • NRB — the domestic (non-prefixed) form of this account number.