Skip to content

Commit ef0c8a0

Browse files
committed
fix(MU): account number is numeric (12!n) per ISO 13616
The SWIFT IBAN Registry BBAN structure for Mauritius is 4!a2!n2!n12!n3!n3!a, so the 12-character account number is digits only. It was declared as CharacterType.c (alphanumeric), which the file's own comment already records as 12!n, so an IBAN with a letter in the account-number field validated as true even though it is structurally invalid (and its check digits are correct). Narrow the account-number class to CharacterType.n. The genuine registry example still validates.
1 parent ae0a547 commit ef0c8a0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/bbanStructure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ export class BbanStructure {
584584
[CountryCode.MU]: new BbanStructure(
585585
BbanStructurePart.bankCode(6, CharacterType.c), // 4!a2!n
586586
BbanStructurePart.branchCode(2, CharacterType.n),
587-
BbanStructurePart.accountNumber(12, CharacterType.c),
587+
BbanStructurePart.accountNumber(12, CharacterType.n),
588588
BbanStructurePart.accountType(3, CharacterType.n),
589589
BbanStructurePart.currencyType(3, CharacterType.a),
590590
),

test/iban.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ describe("IBAN", () => {
1111
it("bad iban", () => {
1212
expect(IBAN.isValid("BA391990440001200278")).toBe(false);
1313
});
14+
it("MU account number must be numeric (12!n)", () => {
15+
// SWIFT IBAN Registry MU BBAN structure is 4!a2!n2!n12!n3!n3!a; the
16+
// account number is 12 digits. A letter in that field is structurally
17+
// invalid even when the check digits are correct (mod-97 == 1 here).
18+
expect(IBAN.isValid("MU84BOMM010110103030020A000MUR")).toBe(false);
19+
// Genuine registry example stays valid.
20+
expect(IBAN.isValid("MU17BOMM0101101030300200000MUR")).toBe(true);
21+
});
1422
});
1523

1624
describe("Test check digit", () => {

0 commit comments

Comments
 (0)