Skip to content

fix(BY): allow digits in the Belarus bank identifier (4!c)#687

Open
spokodev wants to merge 1 commit into
Simplify:masterfrom
spokodev:fix-belarus-bank-code-alphanumeric
Open

fix(BY): allow digits in the Belarus bank identifier (4!c)#687
spokodev wants to merge 1 commit into
Simplify:masterfrom
spokodev:fix-belarus-bank-code-alphanumeric

Conversation

@spokodev

Copy link
Copy Markdown

Problem

The Belarus BBAN structure is 4!c4!n16!c per the ISO 13616 / SWIFT IBAN Registry, where the leading 4-character bank identifier is 4!c — alphanumeric (digits or uppercase letters). The current spec encodes it as [A-Z]{4} (letters only):

BY: { chars: 28, bban_regexp: '^[A-Z]{4}[0-9]{4}[A-Z0-9]{16}$', ... }

As a result, an otherwise-valid Belarus IBAN whose bank code contains a digit is rejected:

const { isValidIBAN } = require('ibantools');

isValidIBAN('BY13NBRB3600900000002Z00AB00');   // true  (bank code = letters)
isValidIBAN('BY26AKB10100000002966000000A');   // false (bank code "AKB1" — BUG)

BY26AKB10100000002966000000A is well-formed: 28 characters, BBAN 4!c4!n16!c, and its mod-97 check digits are valid (remainder 1). The only reason it fails is the bank field rejecting the digit 1.

Fix

Change the bank field from [A-Z]{4} to [A-Z0-9]{4}. The neighbouring branch field [0-9]{4} (4!n) and account field [A-Z0-9]{16} (16!c) are already correct, so this aligns the bank field with the same registry, consistent with prior BBAN-format corrections in this project.

References

  • SWIFT IBAN Registry (ISO 13616): Belarus BBAN 4!c4!n16!c, length 28.

Test

Added an assertion that a Belarus IBAN with a digit in the bank code validates. It fails before the change and passes after; the full suite is green.

The Belarus BBAN structure is 4!c4!n16!c per the ISO 13616 / SWIFT IBAN
Registry, so the 4-character bank identifier is alphanumeric (digits or
uppercase letters), not letters only. The regexp encoded it as [A-Z]{4},
which falsely rejects otherwise-valid Belarus IBANs whose bank code
contains a digit, e.g. BY26AKB10100000002966000000A (mod-97 check digits
are valid). The neighbouring branch field [0-9]{4} (4!n) and account
field [A-Z0-9]{16} (16!c) are already correct; only the bank field was
too strict. Change [A-Z]{4} to [A-Z0-9]{4}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant