-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix meetsAgeRequirements
for min/max dates
#17474
Fix meetsAgeRequirements
for min/max dates
#17474
Conversation
Edit: no need in the end, the QA checklist can be completed without this |
|
Rerunning pullerBear, as I'm leaving on parental leave! |
@s77rt @marcochavezf One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Rerunning pullerBear, as I'm leaving on parental leave! |
Can you please fix this for App/src/libs/ValidationUtils.js Line 226 in af3ae13
The last parameter should be a string, although the empty array also seems to work. |
src/libs/ValidationUtils.js
Outdated
return testDate.isValid() && testDate.isBetween(oneHundredFiftyYearsAgo, eighteenYearsAgo); | ||
|
||
// Only compare the dates (ignore the time), and make the comparison inclusive of the start and end dates | ||
return testDate.isValid() && testDate.isBetween(oneHundredFiftyYearsAgo, eighteenYearsAgo, 'day', '[]'); |
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.
This solution still doesn't work when manually input date older than 1873-04-17 (today - 150 years) as long as picker allows that selection.
I think updating error message is straight forward.
bug.mov
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.
You mean it doesn't work in that the message is technically wrong? Yeah fair point, I'm trying to thing what's the best way to update it:
- Either we can update just the message to be something like "Must be over 18 years old and less than 150 years old", or
- Split the function
meetsAgeRequirements
into two functions, e.g.isBelowAgeRequirement
andisOverAgeRequirement
but that sounds overkill, or - Change the function
meetsAgeRequirements
to return an int, for example-1
if the age is < 18,0
if it's fine,1
if it's over 150 years
Any preference or alternative ideas?
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.
Either 2 or 3, we should introduce new error message right?
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.
You mean it doesn't work in that the message is technically wrong?
correct because this is the main issue we're trying to fix and makes user confused.
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 am fine with either 2 or 3 but what I want to suggest is that "Must be over 18 years old and less than 150 years old" should be split. Because "less than 150 years old" is extreme edge case.
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.
correct because this is the main issue we're trying to fix and makes user confused.
Oooh, admittedly I read the issue too fast and thought the problem that QA reported was that we were showing the error if you selected the oldest possible date in the date selector. But yes you're right, and we should use use a different error message then.
Splitting meetsAgeRequirements
into two functions works for me. I'm checking about the new error message now because it sounds weird to say you have to be less than 150 years old.
…uirementInclusiveComparison
Introduce `meetsMinimumAgeRequirement()` and `meetsMaximumAgeRequirement()` to replace `meetsAgeRequirements()`. The two functions allow us to show a different error message if a given date is too recent or too far back. For the case a given date is too old for an age, we're reusing the existing invalid date error message for simplicity.
Updated, I split |
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.
src/libs/ValidationUtils.js
Outdated
@@ -194,16 +194,27 @@ function isValidPaypalUsername(paypalUsername) { | |||
} | |||
|
|||
/** | |||
* Validate that "date" is between 18 and 150 years in the past | |||
* Validate that a date date meets the minimum age requirement. |
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.
double date
here 😄
These are out of scope, AFAIK we don't have a date restriction on the incorporation date. |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
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.
LGTM 🎉
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.3.7-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.7-3 🚀
|
Details
When we check that someone's date of birth is in the
150 years - 18 years
range, we currently do a comparison that:This change uses splits
meetsAgeRequirements
in two different checks, so that we can use a different error message for each, and also allows the min/max dates to be selected.Fixed Issues
$ #17426
$ #17981
Tests / QA
Please enter a valid date of birth
(orPor favor, introduce una fecha de nacimiento válida
in Spanish)Must be over 18 years old
(orDebe ser mayor de 18 años
in Spanish)Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-04-24.at.2.18.20.PM.mov
Screen.Recording.2023-04-24.at.2.17.54.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Safari doesn't support restrictions in the date selector #16691 (comment), but you can still test selecting the min/max dates and make sure there are no error
Current max date at time of writing this:

Max date + 1 day: error as expected

Desktop
Screen.Recording.2023-04-24.at.2.39.33.PM.mov
iOS
Android