-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Update display name front-end validation to match back-end #14873
Conversation
@mollfpr @youssef-lr 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] |
I'm having trouble getting my iOS simulator to work, but otherwise everything should be ready for review. |
Reviewer Checklist
Screenshots/VideosWeb14873.Web.movMobile Web - Chrome14873.mWeb.Chrome.movMobile Web - Safari14873.mWeb.Safari.mp4Desktop14873.Desktop.moviOS14873.iOS.mp4Android14873.Android.mov |
Input Screen.Recording.2023-02-07.at.14.13.13.mov |
Nice catch @mollfpr. I'll look into it. |
I'm going to bow out of this PR review for #focus. |
Thanks for the thorough review so far @mollfpr. Ready for another round! |
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.
Looks good to me and test well on the RequestCallPage, LegalNamePage, and DisplayNamePage 👍
Here's the checklist!
Thank you @mollfpr! @youssef-lr could you also give this a review please? |
I can take a look 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.
Looking pretty great overall. I like how you have simplified this a lot. There's a few small changes I would like to see. Also I think it would be good to include tests for each page that was modified here, just in case.
if (doesFirstNameHaveInvalidCharacters) { | ||
errors.firstName = this.props.translate('personalDetails.error.hasInvalidCharacter'); | ||
} else if (ValidationUtils.doesContainReservedWord(values.firstName, CONST.DISPLAY_NAME.RESERVED_FIRST_NAMES)) { | ||
errors.firstName = this.props.translate('personalDetails.error.containsReservedWord'); |
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.
:issue We should display multiple error messages at the same time if multiple validations fail, as we state in the form guidelines. For example, if I set my first name to Concierge;
I should see First name cannot contain the words Expensify or Concierge. Name cannot contain a comma or semicolon.
.
suggestion: We can easily join the error messages together.
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.
suggestion: We can easily join the error messages together.
I'm not sure we do this in any of our other forms?
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.
Agreed, could you give an example of a form that does this? Because that would require copy variations and conditions for each combination of errors. Or I guess appending the error to errors.firstName
instead of replacing it.
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 don't think we currently do this in any of our forms. I'll ask in Slack if we want to do this. If not then I'm happy with what we have and we should update the form guidelines.
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.
Here's the Slack discussion.
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 make this a NAB comment. If we decide to make the change I'll create a refactor issue.
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.
Alright sounds good. I'm going to go ahead and merge then. Thanks for starting the slack discussion @neil-marcellini.
Looks good to me and tested well! Just a question @puneetlath, Keeping the first name empty and last name as 'Concierge' will still result in a display name that says 'Concierge'. Is this fine? |
@youssef-lr Yup, we already addressed that here. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Performance Comparison Report 📊Significant Changes To DurationThere are no entries Meaningless Changes To DurationShow entries
Show details
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.2.72-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.2.72-1 🚀
|
Hey everyone, following the BugZero checklist for #15741 here. We implemented the same validation rules for both the "Display name" and the "Legal Name" in this P.R. but I think the latter has different more strict rules (that don't allow special characters for example). Because of that, newDot allowed some special characters in the "Legal Name" fields but after saving it the API was stripping them away in the Onyx response. Video of the bugBug5968608_Gravar__2078.mp4 |
// Then we validate the last name field | ||
if (!ValidationUtils.isValidDisplayName(values.lastName)) { | ||
errors.lastName = this.props.translate('personalDetails.error.hasInvalidCharacter'); | ||
} |
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.
We missed out a case here, we shouldn't had allowed the user to submit empty first name, this caused #44167.
Though i agree this is not actually a bug from this PR, but rather a missed logic.
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.
Thanks for pointing it out!
Details
Updates the display name validation to match the back-end. These are the changes:
maxLength
prop to first and last name fieldsFixed Issues
$ #13779
Tests
Offline tests
Same tests. Everything here should work while offline.
QA Steps
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.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android