Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/forms/idv/doc_pii_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ class DocPiiForm
message: proc {
I18n.t('doc_auth.errors.general.no_liveness')
} }
validate :zipcode_valid?
validates :zipcode, format: {
with: /\A[0-9]{5}(?:-[0-9]{4})?\z/,
message: proc {
I18n.t('doc_auth.errors.general.no_liveness')
},
}

validates :jurisdiction, inclusion: { in: Idp::Constants::STATE_AND_TERRITORY_CODES,
message: proc {
I18n.t('doc_auth.errors.general.no_liveness')
Expand Down Expand Up @@ -82,12 +88,6 @@ def dob_valid?
end
end

def zipcode_valid?
return if zipcode.is_a?(String) && zipcode.present?

errors.add(:zipcode, generic_error, type: :zipcode)
Copy link
Contributor

@aduth aduth Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to have been the only reference to the generic_error method, so we probably ought to remove the method definition as being unreachable code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aduth Good point, I made a follow-up ticket.

end

def generic_error
I18n.t('doc_auth.errors.general.no_liveness')
end
Expand Down
6 changes: 3 additions & 3 deletions spec/forms/idv/doc_pii_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
state: Faker::Address.state_abbr,
}
end
let(:non_string_zipcode_pii) do
let(:invalid_zipcode_pii) do
{
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
dob: valid_dob,
address1: Faker::Address.street_address,
state: Faker::Address.state_abbr,
zipcode: 12345,
zipcode: 123456,
state_id_jurisdiction: 'AL',
}
end
Expand Down Expand Up @@ -174,7 +174,7 @@
end

context 'when there is a non-string zipcode' do
let(:pii) { non_string_zipcode_pii }
let(:pii) { invalid_zipcode_pii }

it 'returns a single generic pii error' do
result = subject.submit
Expand Down