New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more date validation to activities program date #219
Conversation
37f297c
to
9f7f796
Compare
@@ -91,6 +91,7 @@ errors.required-financial-assistance=Please answer whether you need child care a | |||
errors.invalid-date-format=Make sure the date you entered is in this format: mm/dd/yyyy | |||
errors.invalid-birthdate-format=Make sure the birthdate you entered is in this format: mm/dd/yyyy | |||
errors.invalid-birthdate-range=Make sure the date you entered is between 01/01/1901 and today. | |||
errors.invalid-date-range=Make sure the date you entered is after 01/01/1901 and before today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like the error message is the same as errors.invalid-birthdate-range
but is worded weirdly. Should we have the same verbiage as errors.invalid-birthdate-range
? (pending verifying with design)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I can align them.
void shouldErrorWhenStartDateIsBefore1901() { | ||
Map<String, Object> formData = Map.of( | ||
"activitiesProgramStartMonth", "01", | ||
"activitiesProgramStartDay", "", | ||
"activitiesProgramStartYear", "1700", | ||
"activitiesProgramEndMonth", "01", | ||
"activitiesProgramEndDay", "", | ||
"activitiesProgramEndYear", "2024" | ||
); | ||
FormSubmission submission = new FormSubmission(formData); | ||
Map<String, List<String>> errors = validator.runValidation(submission, new Submission()); | ||
assertThat(errors).containsKey("activitiesProgramStart"); | ||
assertThat(errors.get("activitiesProgramStart")).contains("Make sure the date you entered is after 01/01/1901 and before today."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! (Pardon if this is nitpicky) but I tried
....
"activitiesProgramStartMonth", "01",
"activitiesProgramStartDay", "",
"activitiesProgramStartYear", "1901",
...
Not sure if this is a bug but this still throws an error (setting date for the date today does not throw an error, so I was assuming that this is an inclusive between
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic on 01/1901
being inclusive or not is in the VerifyDate action we're extending.
And seeing Carl's message about this in our stand up zoom, I'm going to keep it the same for now as this work didn't change the existing behavior.
"Let’s not worry about it too much. Not many of our dates will actually be on 1/1/1901"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to what @enyia21 says but I left some questions and messages. Thanks Cypress!
29cbf76
to
7d8dc7b
Compare
|
||
String endMonth = inputData.get(INPUT_NAME_END_MONTH).toString(); | ||
String endYear = inputData.get(INPUT_NAME_END_YEAR).toString(); | ||
String endGroup = "activitiesProgramEnd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this code be refactored?
... String startMonthField = startGroup.concat("Month"); String startDayField = startGroup.concat("Day"); String startYearField = startGroup.concat("Year"); ...
This pattern appears to be repeated for the start and end date.
String endGroup = "activitiesProgramEnd"; String endMonthField = endGroup.concat("Month"); String endDayField = endGroup.concat("Day"); String endYearField = endGroup.concat("Year");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looking into this now
@rapicastillo / @enyia21, I've made changes to my PR to address the messaging and DRY up the code |
- Remove old activity date tests as the new ones cover them and more
- Invert isBetweenNowAndMinDate because we always invert it when we use it
d99664d
to
1629fd0
Compare
🔗 Jira ticket
CCAP-21
✍️ Description
This PR is to address comments here in regards to date validation.
01/01/1901
today
activityProgram
dates andpartnerProgram
dates have the same validation✅ Completion tasks