[HOLD for payment 2021-09-17] Change error message copy when an age below 18 is entered in the Requestor Information DoB field
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Go to https://new.expensify.com/bank-account/requestor
- Enter a date of birth that makes the requestor under 18 years old e.g. 2015-01-01
- Fill out all other fields and enable the checkbox
- Click Save & Continue
- See an error message that reads "Please enter a valid date of birth"
Expected Result:
Send a specific error message that reads "Requestors must be over 18 years old"
Actual Result:
We send a vague error message that doesn't communicate the specific problem with the date of birth entry - "Please enter a valid date of birth"
Workaround:
Enter an older date of birth but how would a user know to do that?
Platform:
Where is this issue occurring?
- [x] - Web
- [x] - iOS
- [x] - Android
- [x] - Desktop App
- [x] - Mobile Web
Version Number: v1.0.91-0
Vid:
https://user-images.githubusercontent.com/36425901/131914635-108e4303-36a3-4065-bfb2-90c53103a4fe.mov
Triggered auto assignment to @alexpensify (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.
It looks like the error is thrown from the backend. We could add the same validation on the frontend too.
Proposed Solution
In RequestorStep, we call isValidIdentity. This function exists in ValidationUtils.
Add a new function isValidAge
// Add in CONST
VALID_MIN_AGE: 18
function isValidAge(dob) {
return moment().diff(moment(dob), 'years') > CONST.VALID_MIN_AGE; // or >=
}
and we need to add the following lines in the function after the isValidDate call.
if (!isValidDate(identity.dob)) {
showBankAccountFormValidationError(translateLocal('bankAccount.error.dob'));
showBankAccountErrorModal();
return false;
}
if (!isValidAge(identity.dob)) {
showBankAccountFormValidationError(translateLocal('bankAccount.error.age'));
showBankAccountErrorModal();
return false;
}
Add relevant translations:
en: {
bankAccount: {
error: {
age: 'Requestors must be over 18 years old',
}
}
}
// and add the same for Spanish
es: {
bankAccount: {
error: {
age: 'Los solicitantes deben ser mayores de 18 aΓ±os',
}
}
}
One small addition can be made to the translation by keeping the age dynamic:
age: (age) => `Requestors must be over ${age} years old`,
// and pass in the translate call as:
showBankAccountFormValidationError(translateLocal('bankAccount.error.age', {age: CONST.VALID_MIN_AGE}))
Triggered auto assignment to @adelekennedy (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
@alexpensify is out until Tuesday. Issue looks good and good external candidate!
Created a job in Upwork!
Internal: https://www.upwork.com/ab/applicants/1433924712138452992/job-details External: https://www.upwork.com/jobs/~0193c7ce2cc67ec805
Triggered auto assignment to @pecanoro (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Adding a test will fix it
Not overdue
The proposal is good, I am not sure if I would add the constant though, it seems a bit overkill. However, besides that, it looks good.
Can do without the const
@akshayasalvi just hired you in Upwork!
PR raised
:hand: 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 @pecanoro in version: 1.0.95-2 π
| platform | result |
|---|---|
| π€ android π€ | success β |
| π₯ desktop π₯ | success β |
| π iOS π | success β |
| πΈ web πΈ | success β |
π Deployed to production by @roryabraham in version: 1.0.96-0 π
| platform | result |
|---|---|
| π€ android π€ | success β |
| π₯ desktop π₯ | success β |
| π iOS π | success β |
| πΈ web πΈ | success β |
@akshayasalvi paid you through Upwork and ended the contract, the job is now closed!