From 0f4f5c43c8cf322ba75b56ade5c9d0ea2d644f4b Mon Sep 17 00:00:00 2001 From: Yarchik Date: Mon, 22 Jun 2026 20:43:40 +0100 Subject: [PATCH] fix(BY): allow digits in the Belarus bank identifier (4!c) 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}. --- src/ibantools.ts | 2 +- test/ibantools_test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ibantools.ts b/src/ibantools.ts index f565bdd..b97c5ce 100755 --- a/src/ibantools.ts +++ b/src/ibantools.ts @@ -1038,7 +1038,7 @@ export const countrySpecs: CountryMapInternal = { BW: {}, BY: { chars: 28, - bban_regexp: '^[A-Z]{4}[0-9]{4}[A-Z0-9]{16}$', + bban_regexp: '^[A-Z0-9]{4}[0-9]{4}[A-Z0-9]{16}$', IBANRegistry: true, bank_identifier: '0-3', }, diff --git a/test/ibantools_test.js b/test/ibantools_test.js index 037a995..de0ab76 100644 --- a/test/ibantools_test.js +++ b/test/ibantools_test.js @@ -33,6 +33,9 @@ describe('IBANTools', function() { it('with valid BY IBAN should return true', function() { return expect(iban.isValidIBAN('BY13NBRB3600900000002Z00AB00')).to.be.true; }); + it('with valid BY IBAN whose bank code contains a digit should return true', function() { + return expect(iban.isValidIBAN('BY26AKB10100000002966000000A')).to.be.true; + }); it('with valid CR IBAN should return true', function() { return expect(iban.isValidIBAN('CR25010200009074883572')).to.be.true; });