Fix: Name is not validated in Connect Bank account page - #30674
Conversation
|
@0xmiroslav Please 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] |
| } | ||
|
|
||
| function isValidName(value: string) { | ||
| return /^[^\d\s!@#$%^&*(),.?":{}|<>]+$/.test(value); |
There was a problem hiding this comment.
I think we can have better regex than this. So allow only language alphabets
There was a problem hiding this comment.
I think there're cases where names not only contain alphabet characters. For example Musk's daughter: X Æ A-12 Musk. Anw, there must be a reason why Onfindo did not forbid all special characters for names here.
There was a problem hiding this comment.
Rename to isValidPersonName and move to Line 298 so it's below isValidDisplayName and isValidLegalName
There was a problem hiding this comment.
I think there're cases where names not only contain alphabet characters. For example Musk's daughter:
X Æ A-12 Musk. Anw, there must be a reason why Onfindo did not forbid all special characters for names here.
X Æ A-12 Musk what you said is treated as invalid
There was a problem hiding this comment.
So what's your final approach? Only allow alphabetic and latin chars like we already did here, or follow Onfindo's rules as above?
There was a problem hiding this comment.
I'm stuck on testing on Onfido since I don't have the API TOKEN. IMO, I think we should use the regex above because it matches the Onfido regex and prevent numbers. What do you think?
There was a problem hiding this comment.
I am fine as long as frontend regex is equal to or more strict than backend/onfido regex.
So what I am just concerned is the case when frontend check pass but onfido check failure as this is what we're trying to fix here.
There was a problem hiding this comment.
I'm stuck on testing on Onfido since I don't have the API TOKEN
You can test through newDot. Why not just check if fails in backend or not?
There was a problem hiding this comment.
@0xmiroslav I believe my regex above above is more strict than onfido's one because it restricts the numbers.
So what I am just concerned is the case when frontend check pass but onfido check failure as this is what we're trying to fix here.
I checked the non-latin character and it passed
Screen.Recording.2023-11-17.at.14.44.37.mov
There was a problem hiding this comment.
ok please add automated test cases as many corner cases as possible, both success and failure
|
@0xmiroslav can we continue? |
|
Also, add automated test cases |
|
@0xmiroslav Added tests |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
|
@stitesExpensify Can you help review my PR when you have a chance? Thanks |
stitesExpensify
left a comment
There was a problem hiding this comment.
LGTM, just one quick request please
| test('Valid person name', () => { | ||
| expect(ValidationUtils.isValidPersonName('test name')).toBe(true); | ||
| expect(ValidationUtils.isValidPersonName(`X Æ A test`)).toBe(true); | ||
| }); |
There was a problem hiding this comment.
Can we add a quick test for a hyphenated last name such as a hypenated-name? This is fairly common so I just want to make sure it doesn't ever get broken
|
@stitesExpensify updated |
stitesExpensify
left a comment
There was a problem hiding this comment.
Looks great, thanks!
|
✋ 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 production by https://github.com/mountiny in version: 1.4.6-2 🚀
|
| /** | ||
| * Checks that the provided name doesn't contain special characters or numbers | ||
| */ | ||
| function isValidPersonName(value: string) { | ||
| return /^[^\d^!#$%*=<>;{}"]+$/.test(value); | ||
| } |
There was a problem hiding this comment.
Hi folks, this RegExp allows symbols like "?" or "@" – did you consider using the CONST.REGEX.ALPHABETIC_AND_LATIN_CHARS here, or do we allow non-latin symbols in the names?
There was a problem hiding this comment.
We allow non-latin symbols in the name to match Onfindo's validation rules. You can read more in our disucssion here.
There was a problem hiding this comment.
Yes, just found it, thanks 👍
Details
Name is not validated properly on client side in Connect Bank account page. This PR fixes that.
Fixed Issues
$ #27390
PROPOSAL: #27390 (comment)
Tests
^!#$%*=<>;{}"or numbers)Please enter valid first nameorPlease enter valid last nameerror appears under first name or last name fieldOffline tests
NA
QA Steps
^!#$%*=<>;{}"or numbers)Please enter valid first nameorPlease enter valid last nameerror appears under first name or last name fieldPR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop