Skip to content
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

VBA Fields validation #5531

Merged
merged 10 commits into from
Oct 4, 2021
Merged

Conversation

akshayasalvi
Copy link
Contributor

@akshayasalvi akshayasalvi commented Sep 25, 2021

@puneetlath Can you please review this?

Details

  • Added regex for phone validation
  • Added maxLength and keyboardType for fields

Fixed Issues

$ #5184

Tests

  1. Tested the phone number with brackets and with long digits
  2. Tested ssn with more than 4 digits
  3. Tested taxIDNumber with more than 9 digits
  4. Tested zipCode with more than 5 digits

QA Steps

There are two forms where the validation is added.

Company Step

  1. Got to bank-account/company-step
  2. Enter invalid values for zipCode, taxIDNumber and phoneNumber
  3. Click on Save & Continue
  4. Validate that fields show the error

Requestor Step

  1. Got to bank-account/personal-information
  2. Enter invalid values for ssn
  3. Click on Save & Continue
  4. Validate that fields show the error

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

web-ssn-error

web-ssn-valid

web-validation-errors

web-valid-values

Mobile Web

mweb-validation-errors

mweb-valid-values-001

mweb-valid-values-002

mweb-ssn-error

mweb-ssn-valid

Desktop

desktop-validation-errors

desktop-valid-values

desktop-ssn-error

desktop-ssn-valid

iOS

ios-validation-errors

ios-valid-values

ios-ssn-error

ios-ssn-valid

Android

android-validation-errors

android-valid-values

android-ssn-error

android-ssn-value

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@akshayasalvi akshayasalvi requested a review from a team as a code owner September 25, 2021 19:12
@MelvinBot MelvinBot requested review from puneetlath and removed request for a team September 25, 2021 19:12
@akshayasalvi
Copy link
Contributor Author

@puneetlath We might have to update the placeholder for Phone number field. At the moment it says 10 digits, no hyphens. Can you or @SofiedeVreese help me with the new placeholder that I can update?

@Luke9389
Copy link
Contributor

@akshayasalvi Regarding the phone number placeholder, I think it's fine to just use Phone Number (xxx)xxx-xxxx .

Also, I think you should use Str.isValidPhone from expensify-common in the validate() method on this form.

@Luke9389 Luke9389 self-assigned this Sep 28, 2021
@Luke9389
Copy link
Contributor

Hey @akshayasalvi, great job so far on this issue. 👍

We are wanting to push through all issues related to this flow very quickly, so it's possible that I'll end up taking this PR and finishing it personally. Rest assured, you will still get paid as if you completed this issue. I'll check back in tomorrow and make a determination then.

@akshayasalvi
Copy link
Contributor Author

@akshayasalvi Regarding the phone number placeholder, I think it's fine to just use Phone Number (xxx)xxx-xxxx .

Same placeholder in Spanish too?

Also, I think you should use Str.isValidPhone from expensify-common in the validate() method on this form.

I had seen that but it seems our current isValidPhone only allows digits and not parenthesis? I had even raised it in the discussion here #5184 (comment)

Hey @akshayasalvi, great job so far on this issue. 👍

Thank you

We are wanting to push through all issues related to this flow very quickly, so it's possible that I'll end up taking this PR and finishing it personally. Rest assured, you will still get paid as if you completed this issue. I'll check back in tomorrow and make a determination then.

Okay both the changes that you've mentioned have follow-up questions. Can you help so that I'll update the PR at the earliest?

@Luke9389
Copy link
Contributor

Same placeholder in Spanish too?

That's a good point. For Spanish, lets do (prefijo) + (número).

@Luke9389
Copy link
Contributor

I had seen that but it seems our current isValidPhone only allows digits and not parenthesis? I had even raised it in the discussion here #5184 (comment)

You also offered taking out the parentheses in that comment, which sounds like a fine solution to me. We don't need to make that a separate method, just do it in one line.

Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is looking really good. Let me know what you think about my concern with de-coupling the max length of phone numbers and their symbols.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…-validation

# Conflicts:
#	src/pages/ReimbursementAccount/CompanyStep.js
#	src/pages/ReimbursementAccount/IdentityForm.js
@akshayasalvi
Copy link
Contributor Author

I think this is looking really good. Let me know what you think about my concern with de-coupling the max length of phone numbers and their symbols.

@Luke9389 I've updated the regex with length check on the numbers. I've also added an additional max length check in the function itself.

Also, I saw two conflicts where I've picked my changes. I insist on keeping my change keyboardType={CONST.KEYBOARD_TYPE.NUMERIC} whereas the incoming change had it set as KEYBOARD_TYPE.PHONE_PAD with fields like zipCode and ssnLast4 being numbers only.

Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting closer, just a few more questions. Thanks!

…-validation

# Conflicts:
#	src/libs/ValidationUtils.js
#	src/pages/ReimbursementAccount/CompanyStep.js
@akshayasalvi
Copy link
Contributor Author

PR updated

Luke9389
Luke9389 previously approved these changes Sep 30, 2021
Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging I'd like to verify that you've tested these changes since the most recent commit. I ask all my contributors this question because it's easy to assume our commits don't break anything, and then they cause regressions. Lets get you paid on time :)

@akshayasalvi
Copy link
Contributor Author

Yes tested :)

…-validation

# Conflicts:
#	src/libs/ValidationUtils.js
@akshayasalvi
Copy link
Contributor Author

@Luke9389 Resolved and tested again

@Luke9389
Copy link
Contributor

Luke9389 commented Oct 4, 2021

@akshayasalvi Looks like there's another conflict.

@akshayasalvi
Copy link
Contributor Author

@akshayasalvi Looks like there's another conflict.

Ohh no :(

@Luke9389
Copy link
Contributor

Luke9389 commented Oct 4, 2021

Heh, it's OK! No worries, just be sure you're merging with the most recent version of our main branch.
Usually, I run git fetch to help with this. (Though, if you want to be 200% sure, checkout main and run git fetch && git pull)

…-validation

# Conflicts:
#	src/pages/ReimbursementAccount/IdentityForm.js
@akshayasalvi
Copy link
Contributor Author

Resolved again and tested

Heh, it's OK! No worries, just be sure you're merging with the most recent version of our main branch. Usually, I run git fetch to help with this. (Though, if you want to be 200% sure, checkout main and run git fetch && git pull)

Yeah, I do it every time. It is just other changes are getting merged and resulting in conflicts. I am guessing these screens are under active development.

@Luke9389 Luke9389 merged commit 817240d into Expensify:main Oct 4, 2021
@OSBotify
Copy link
Contributor

OSBotify commented Oct 4, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 6, 2021

🚀 Deployed to staging by @Luke9389 in version: 1.1.5-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@isagoico
Copy link

isagoico commented Oct 7, 2021

This issue is failing this PR #5705

@puneetlath
Copy link
Contributor

Hm, that seems like a separate issue rather than a regression caused by this PR. This PR just enforces that what is entered is the right type and length. But doesn't do any validation on whether the numbers entered are valid. So I don't think we need to block this PR based on that.

@isagoico
Copy link

isagoico commented Oct 7, 2021

oh ok then the PR is a pass! Checking it off and removing the deploy blocker label

@Luke9389
Copy link
Contributor

Luke9389 commented Oct 7, 2021

As long as @kavimuru used the correct number of zeros in the phone number. If they were able to pass this step with just one zero for a phone number, then I think that's a problem for this PR.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 7, 2021

🚀 Deployed to production by @chiragsalian in version: 1.1.6-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@marcaaron
Copy link
Contributor

Just noticed the regex initially added here allows people to enter phone numbers that are only 3 digits ?

Seems like something is wrong? Or is that expected..?

2021-10-15_07-25-11

@akshayasalvi
Copy link
Contributor Author

Just noticed the regex initially added here allows people to enter phone numbers that are only 3 digits?

Yeah, it allows because our current regex also allows 3 digit numbers. This one adds support for brackets, etc. in US format, yet allows you to add 2-3 digit numbers as per E164

@marcaaron
Copy link
Contributor

Yes, that's good. But what 3 digit number are they entering that we should accept as a phone number?

@akshayasalvi
Copy link
Contributor Author

Yes, that's good. But what 3 digit number are they entering that we should accept as a phone number?

Good question. I am not sure then what would be the expected values. Can you help me and accordingly I'll update the regex. This is the current regex: /^\+?[1-9]\d{1,14}$/

@Luke9389
Copy link
Contributor

Luke9389 commented Oct 18, 2021

Yea, we should have enforced a minimum character amount. A quick search turned up with 5 as the absolute minimum number of digits (Solomon Islands). Runner up is Sweden at 7.
https://stackoverflow.com/questions/14894899/what-is-the-minimum-length-of-a-valid-international-phone-number

@marcaaron
Copy link
Contributor

Nice. Should we create a new issue? It'd be great to try and avoid any situation where a user is able to do something that we can catch with front end validation instead of in the back end.

@Luke9389
Copy link
Contributor

Yea, I'm fine with just spinning one up real quick and doing it. I don't think it's worth Exporting.

Before I do that though, do you think we should try to factor in location to this check? We could look at the address they've provided (if they've done that field) and/or use an IP goelocation lookup?

As I'm writing this it sounds like overkill, but I'd like to prevent someone from providing a 5 digit phone number (likely as an accident). What do you think?

@marcaaron
Copy link
Contributor

Good thoughts, but agree with it being overkill for now. The case I was running into specifically is that I had an area code previously saved auto-filling in this input so adding a minimum like 5 digits here seems like a high value improvement given the complexity added.

@Luke9389
Copy link
Contributor

K, I'll just spin this up and do it. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants