From d5a4b975b75396468720c07780d5e0eeed66551b Mon Sep 17 00:00:00 2001 From: Vinay P Date: Fri, 22 Feb 2019 15:15:41 +0000 Subject: [PATCH] Allow digits only in US ACH account numbers the validation rule allows an underscore because that's the padding character for account numbers shorter than 17 digits, but that's OK to allow because we remove leading padding characters. --- data/structures.yml | 3 +-- spec/ibandit/iban_spec.rb | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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