From 6d3c9bb678141ae628d0ccd42fac15869ffca990 Mon Sep 17 00:00:00 2001 From: Oleg Sashko Date: Fri, 11 Sep 2026 11:28:47 +0300 Subject: [PATCH 1/2] Require NZ account number suffix to start with a zero --- CHANGELOG.md | 4 ++++ README.md | 21 +++++++++++++-------- data/raw/pseudo_ibans.yml | 2 +- data/structures.yml | 2 +- lib/ibandit/version.rb | 2 +- spec/ibandit/iban_spec.rb | 19 +++++++++++++++---- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c69a185..d3590af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.34.0 - September 11, 2026 + +- [Breaking] Reject NZ account numbers whose 3 digit suffix does not start with a zero + ## 1.33.0 - September 2, 2026 - Update BLZ data - BLZ_20260907 diff --git a/README.md b/README.md index 583bc45..af21cd9 100644 --- a/README.md +++ b/README.md @@ -548,20 +548,25 @@ iban = Ibandit::IBAN.new( iban.pseudo_iban # => "NZZZ0100043333333044" iban.iban # => nil +# A 2 digit suffix is padded with a leading zero. A suffix given as 3 digits +# must already start with that zero: `SS` becomes `0SS`, never `SS0`. + iban = Ibandit::IBAN.new( country_code: 'NZ', account_number: '01-0004-3333333-44' ) -iban.pseudo_iban # => "NZZZ0100043333333044" -iban.bank_code # => "01" -iban.branch_code # => "0004" -iban.account_number # => "3333333044" +iban.pseudo_iban # => "NZZZ0100043333333044" +iban.bank_code # => "01" +iban.branch_code # => "0004" +iban.account_number # => "3333333" +iban.account_number_suffix # => "044" iban = Ibandit::IBAN.new('NZZZ0100043333333044') -iban.country_code # => "NZ" -iban.bank_code # => "01" -iban.branch_code # => "0004" -iban.account_number # => "3333333044" +iban.country_code # => "NZ" +iban.bank_code # => "01" +iban.branch_code # => "0004" +iban.account_number # => "3333333" +iban.account_number_suffix # => "044" # USA iban = Ibandit::IBAN.new( diff --git a/data/raw/pseudo_ibans.yml b/data/raw/pseudo_ibans.yml index 0cecd94..687a34a 100644 --- a/data/raw/pseudo_ibans.yml +++ b/data/raw/pseudo_ibans.yml @@ -35,7 +35,7 @@ NZ: :account_number_length: 10 :bank_code_format: "\\d{2}" :branch_code_format: "\\d{4}" - :account_number_format: "\\d{7}\\d{3}" + :account_number_format: "\\d{7}0\\d{2}" :pseudo_iban_bank_code_length: 2 :pseudo_iban_branch_code_length: 4 :pseudo_iban_account_number_length: 10 diff --git a/data/structures.yml b/data/structures.yml index e89db5c..79bef5b 100644 --- a/data/structures.yml +++ b/data/structures.yml @@ -1598,7 +1598,7 @@ NZ: :account_number_length: 10 :bank_code_format: "\\d{2}" :branch_code_format: "\\d{4}" - :account_number_format: "\\d{7}\\d{3}" + :account_number_format: "\\d{7}0\\d{2}" :pseudo_iban_bank_code_length: 2 :pseudo_iban_branch_code_length: 4 :pseudo_iban_account_number_length: 10 diff --git a/lib/ibandit/version.rb b/lib/ibandit/version.rb index 39c3d7a..5f030fc 100644 --- a/lib/ibandit/version.rb +++ b/lib/ibandit/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Ibandit - VERSION = "1.33.0" + VERSION = "1.34.0" end diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 1b630ed..9460a13 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -764,23 +764,34 @@ end context "with a 3 digit account number suffix" do - let(:account_number) { "3333333-944" } + let(:account_number) { "3333333-044" } its(:country_code) { is_expected.to eq("NZ") } its(:bank_code) { is_expected.to eq("11") } its(:branch_code) { is_expected.to eq("2222") } its(:account_number) { is_expected.to eq("3333333") } - its(:account_number_suffix) { is_expected.to eq("944") } + its(:account_number_suffix) { is_expected.to eq("044") } its(:swift_bank_code) { is_expected.to eq("11") } its(:swift_branch_code) { is_expected.to eq("2222") } - its(:swift_account_number) { is_expected.to eq("3333333944") } + its(:swift_account_number) { is_expected.to eq("3333333044") } its(:swift_national_id) { is_expected.to eq("112222") } its(:iban) { is_expected.to be_nil } - its(:pseudo_iban) { is_expected.to eq("NZZZ1122223333333944") } + its(:pseudo_iban) { is_expected.to eq("NZZZ1122223333333044") } its(:valid?) { is_expected.to eq(true) } its(:to_s) { is_expected.to eq("") } end + context "with a 3 digit account number suffix not starting with a zero" do + let(:account_number) { "3333333-500" } + + its(:account_number_suffix) { is_expected.to eq("500") } + + it "is invalid and has the correct errors" do + expect(subject.valid?).to eq(false) + expect(subject.errors).to eq(account_number: "format is invalid") + end + end + context "with a 2 digit account number suffix" do let(:account_number) { "3333333-44" } From 6412d26295f69717684ffe8ab0a01e2aeaa2e1d1 Mon Sep 17 00:00:00 2001 From: Oleg Sashko Date: Fri, 11 Sep 2026 16:52:47 +0300 Subject: [PATCH 2/2] Remove disabled // comments from German test fixtures (invalid JSON) --- .../germany_integration_test_cases.json | 21 ------------------- spec/fixtures/germany_unit_test_cases.json | 6 ------ 2 files changed, 27 deletions(-) diff --git a/spec/fixtures/germany_integration_test_cases.json b/spec/fixtures/germany_integration_test_cases.json index 87d7d0e..07c95b3 100644 --- a/spec/fixtures/germany_integration_test_cases.json +++ b/spec/fixtures/germany_integration_test_cases.json @@ -12,15 +12,6 @@ { "bank_code": "10060198", "account_number" : "1" } ] }, - // { - // "convertor": "000300", - // "valid": [ - // { "bank_code": "51010800", "account_number" : "1" } - // ], - // "invalid": [ - // { "bank_code": "51010800", "account_number" : "6161604670" } - // ] - // }, { "convertor": "000400", "valid": [ @@ -91,12 +82,6 @@ {"bank_code":"51020000","account_number":"30009963","converted_bank_code":"50020200","converted_account_number":"30009963"} ] }, - // { - // "convertor": "000900", - // "valid": [ - // {"bank_code":"68351976","account_number":"1116232594","converted_bank_code":"68351557","converted_account_number":"3047232594"} - // ] - // }, { "convertor": "001001", "valid": [ @@ -157,10 +142,4 @@ { "bank_code": "30060010", "account_number": "12345678", "converted_account_number": "12345678" } ] } - // { - // "convertor": "001900", - // "valid": [ - // { "bank_code": "50130100", "account_number": "556", "converted_bank_code": "50120383" } - // ] - // } ] diff --git a/spec/fixtures/germany_unit_test_cases.json b/spec/fixtures/germany_unit_test_cases.json index 303a970..e94c806 100644 --- a/spec/fixtures/germany_unit_test_cases.json +++ b/spec/fixtures/germany_unit_test_cases.json @@ -136,12 +136,6 @@ { "bank_code": "10010010", "account_number" : "556", "converted_account_number": "0120440110" } ] }, - // { - // "convertor": "001900", - // "valid": [ - // { "bank_code": "10010010", "account_number" : "1234567890", "converted_bank_code": "50120383" } - // ] - // }, { "convertor": "002002", "valid": [