LG-13896: State ID expiration validation#10995
Merged
Conversation
app/forms/idv/doc_pii_form.rb
Outdated
Contributor
There was a problem hiding this comment.
I might rename this to make it a little clearer what's being checked?
Suggested change
| validate :expired? | |
| validate :state_id_expiration? |
Contributor
There was a problem hiding this comment.
Adding on to this comment:
- The method doesn't return a boolean, so I wouldn't expect a
?suffix - Most of our "validate" methods are prefixed with
validate_
Suggested change
| validate :expired? | |
| validate :validate_state_id_expiration |
Comment on lines
11
to
15
Contributor
There was a problem hiding this comment.
I just realized this is the same regex as DateParser::AMERICAN_REGEX, maybe we could reuse that code here?
Suggested change
| ['dob', 'state_id_expiration'].each do |dt| | |
| if (m = data.dig('document', dt).to_s. | |
| match(%r{(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{4})})) | |
| data['document'][dt] = | |
| Date.new(m[:year].to_i, m[:month].to_i, m[:day].to_i) | |
| end | |
| end | |
| %w[dob state_id_expiration].each do |date_key| | |
| if (date_s = data.dig('document', date_key')) | |
| data['document'][date_key] = DateParser.parse_legacy(date_s) | |
| end | |
| rescue Date::Error | |
| # maybe don't rescue so we get the error? | |
| end |
theabrad
approved these changes
Aug 5, 2024
Contributor
theabrad
left a comment
There was a problem hiding this comment.
LGTM. Tested locally with a yml file that had an expired ID and was sent to the "Try again" page.
… state ID expiration date
5bd27b5 to
bb3fe0a
Compare
jmax-gsa
approved these changes
Aug 5, 2024
| ['dob', 'state_id_expiration'].each do |date_key| | ||
| if (date_s = data.dig('document', date_key)) | ||
| data['document'][date_key] = DateParser.parse_legacy(date_s) | ||
| end |
Contributor
There was a problem hiding this comment.
Hah! I just got done writing a very similar code block here independently while working on LG-13517. I think our PRs are going to mesh nicely. Excellent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎫 Ticket
LG-13896
🛠 Summary of changes
Check to see if the the state ID expiration date has not past when validating user data extracted from the ID.
📜 Testing Plan
Provide a checklist of steps to confirm the changes.