diff --git a/lib/ibandit/iban.rb b/lib/ibandit/iban.rb index 05ec343..f0aa7f5 100644 --- a/lib/ibandit/iban.rb +++ b/lib/ibandit/iban.rb @@ -373,7 +373,7 @@ def valid_ca_details? def valid_australian_details? return true unless country_code == "AU" - bsb_check? + bsb_check? && account_number_not_all_zeros? end def bsb_check? @@ -512,5 +512,12 @@ def pseudo_iban?(input) return false if input.nil? input.slice(2, 2) == Constants::PSEUDO_IBAN_CHECK_DIGITS end + + def account_number_not_all_zeros? + return true if @swift_account_number.to_s.chars.uniq != ["0"] + + @errors[:account_number] = Ibandit.translate(:is_invalid) + false + end end end diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 1dd1fbf..e81c5c6 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -273,6 +273,23 @@ its(:valid?) { is_expected.to eq(true) } its(:to_s) { is_expected.to eq("") } end + + context "and an account number that is all zero" do + let(:account_number) { "000000" } + + its(:country_code) { is_expected.to eq("AU") } + its(:bank_code) { is_expected.to be_nil } + its(:branch_code) { is_expected.to eq("123456") } + its(:account_number) { is_expected.to eq("0000000000") } + its(:swift_bank_code) { is_expected.to be_nil } + its(:swift_branch_code) { is_expected.to eq("123456") } + its(:swift_account_number) { is_expected.to eq("0000000000") } + its(:swift_national_id) { is_expected.to eq("123456") } + its(:iban) { is_expected.to be_nil } + its(:pseudo_iban) { is_expected.to eq("AUZZ1234560000000000") } + its(:valid?) { is_expected.to eq(false) } + its(:to_s) { is_expected.to eq("") } + end end context "when the IBAN was created from an Australian pseudo-IBAN" do