Skip to content

NRB

NRB (Numer Rachunku Bankowego) is Poland’s 26-digit domestic bank account number, verified using the MOD-97 checksum from the IBAN standard. An NRB is structurally the numeric portion of a Polish IBAN (i.e. the IBAN without the PL prefix).

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

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

MethodReturn typeDescription
getRaw()stringThe original input, untouched.
getNormalized()string26 raw digits (prefix and spaces stripped).
toString()stringAlias for getNormalized().
MethodReturn typeDescription
getFormatted()stringHuman-readable form: CC NNNN NNNN NNNN NNNN NNNN NNNN.
getIban()stringFull Polish IBAN: PL + 26 digits.
getFormattedIban()stringHuman-readable IBAN: PLCC NNNN NNNN NNNN NNNN NNNN NNNN.
MethodReturn typeDescription
getCheckDigits()stringFirst 2 digits — MOD-97 check digits.
getSortCode()stringDigits 2–9 (8 digits) — bank sort code.
getBankCode()stringDigits 2–4 (3 digits) — bank identifier.
getAccountNumber()stringDigits 10–25 (16 digits) — customer account number.
const nrb = Numerik.nrb().parse('61102010260000000000000000')
nrb.getRaw() // '61102010260000000000000000'
nrb.getNormalized() // '61102010260000000000000000'
nrb.getFormatted() // '61 1020 1026 0000 0000 0000 0000'
nrb.getIban() // 'PL61102010260000000000000000'
nrb.getFormattedIban() // 'PL61 1020 1026 0000 0000 0000 0000'
nrb.getCheckDigits() // '61'
nrb.getSortCode() // '10201026'
nrb.getBankCode() // '102'
nrb.getAccountNumber() // '0000000000000000'
ReasonValueWhen
InvalidLengthinvalid_lengthInput is not exactly 26 digits after normalisation.
InvalidCharactersinvalid_charactersCharacters other than digits, spaces, and an optional PL prefix are present.
InvalidChecksuminvalid_checksumMOD-97 check digit does not match.

Uses the MOD-97 algorithm from ISO 13616 (IBAN standard):

  1. Reject inputs longer than 40 characters. Strip spaces and hyphens, and an optional PL prefix.
  2. Assert exactly 26 digits remain.
  3. Rearrange: move the first 2 digits (the check digits) to the end and insert the numeric country code for Poland (2521) between the remaining 24 digits and them, giving a 30-digit string.
  4. Compute the 30-digit string modulo 97. The result must equal 1.