Skip to content

Commit

Permalink
fix(bic): bank code validation ISO-9362:2022 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
krazibit authored Jul 12, 2024
1 parent 43bda94 commit 7506ccb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bicUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function validateCase(bic: string) {
function validateBankCode(bic: string) {
const bankCode = getBankCode(bic);

if (!ucRegex.test(bankCode)) {
throw new FormatException(FormatViolation.BANK_CODE_ONLY_LETTERS, "Bank code must contain only letters.", bankCode);
if (!ucnumRegex.test(bankCode)) {
throw new FormatException(FormatViolation.BANK_CODE_ONLY_LETTERS, "Bank code must contain only letters or digits.", bankCode);
}
}

Expand Down
6 changes: 6 additions & 0 deletions test/bic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ describe("BIC", () => {
expect(bic.getBankCode()).toBe("DEUT");
});

it("bank code alphanum", () => {
const bic = new BIC("E097AEXXXXX");

expect(bic.getBankCode()).toBe("E097");
});

it("country code", () => {
const bic = new BIC("DEUTDEFF500");

Expand Down

0 comments on commit 7506ccb

Please sign in to comment.