diff --git a/data/structures.yml b/data/structures.yml index ccc09e8..37d96bb 100644 --- a/data/structures.yml +++ b/data/structures.yml @@ -902,8 +902,7 @@ US: :branch_code_length: 0 :account_number_length: 17 :bank_code_format: "\\d{9}" - # TODO: update account number format based on inputs from user research - :account_number_format: ".{1,17}" + :account_number_format: "\\A_*\\d{1,17}\\z" :national_id_length: 9 :pseudo_iban_bank_code_length: 9 :pseudo_iban_branch_code_length: 0 diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 91c6921..8e5e516 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -724,7 +724,7 @@ its(:to_s) { is_expected.to eq("") } end - context "when the input is an invalid US pseudo-IBAN" do + context "when the input pseudo-IBAN has an invalid US bank_code" do let(:arg) { "USZZ__012345601234567890123456" } it "is invalid and has the correct errors" do @@ -733,6 +733,15 @@ to eq(bank_code: "is the wrong length (should be 9 characters)") end end + + context "when the input pseudo-IBAN has an invalid US account_number" do + let(:arg) { "USZZ965498456ABC01234567890123" } + + it "is invalid and has an error populated" do + expect(subject.valid?).to eq(false) + expect(subject.errors).to eq(account_number: "is invalid") + end + end end describe "#to_s" do