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

Paypal username field validation #5842

Merged
merged 7 commits into from
Oct 19, 2021

Conversation

akshayasalvi
Copy link
Contributor

@akshayasalvi akshayasalvi commented Oct 14, 2021

cc - @parasharrajat

Details

  • Added validations for Paypal.me username

Fixed Issues

$ #5541

Tests

  1. Tested invalid with special characters
  2. Tested invalid with spaces
  3. Tested valid with alphanumeric characters in

QA Steps

  1. Go to Sidebar -> Payments
  2. Select Paypal to add a username
  3. Try updating with the special characters, spaces. Paypal username allows only alphabets and numbers only.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

web-invalid-username-special-chars

web-invalid-username

valid-username

Mobile Web

mweb-invalid-username

Desktop

desktop-invalid-username

iOS

ios-invalid-username

Android

android-invalid-username

@akshayasalvi akshayasalvi requested a review from a team as a code owner October 14, 2021 04:09
@MelvinBot MelvinBot requested review from deetergp and removed request for a team October 14, 2021 04:09
Copy link
Contributor

@deetergp deetergp left a comment

Choose a reason for hiding this comment

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

Code tests well, but there are two typos that need to be addressed.

@@ -282,6 +282,7 @@ export default {
addPayPalAccount: 'Add PayPal account',
editPayPalAccount: 'Update PayPal account',
growlMessageOnSave: 'Your PayPal username was successfully added',
formatError: 'Invalid PayPa.me username',
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing an l — should be PayPal.me

@@ -282,6 +282,7 @@ export default {
addPayPalAccount: 'Agregar cuenta de PayPal',
growlMessageOnSave: 'Su nombre de usuario de PayPal se agregó correctamente',
editPayPalAccount: 'Actualizar cuenta de PayPal',
formatError: 'Usuario PayPa.me no válido',
Copy link
Contributor

Choose a reason for hiding this comment

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

Also missing the l in PayPal

@akshayasalvi
Copy link
Contributor Author

Code tests well, but there are two typos that need to be addressed.

@deetergp PR updated. Typos fixed. Sorry about that.

@deetergp
Copy link
Contributor

@akshayasalvi Typos happen — no big deal!

deetergp
deetergp previously approved these changes Oct 14, 2021
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

Few changes. @deetergp Please wait before the merge.

@@ -282,6 +282,7 @@ export default {
addPayPalAccount: 'Add PayPal account',
editPayPalAccount: 'Update PayPal account',
growlMessageOnSave: 'Your PayPal username was successfully added',
formatError: 'Invalid PayPal.me username',
Copy link
Member

Choose a reason for hiding this comment

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

NAB: Sorry for being Nit-picky. but this does not sound friendly. You can ask this on Slack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've asked, lets see if we get any response. Any suggestions from your side?

Copy link
Member

Choose a reason for hiding this comment

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

I am not really good with content but this is not really blocking this so if you don't get any feedback, then it's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay got it. Thanks for the help.

*
* @returns {Boolean}
*/
validatePaypalMeUsername() {
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this to ValidationUtils.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -92,6 +114,9 @@ class AddPayPalMePage extends React.Component {
placeholder={this.props.translate('addPayPalMePage.yourPayPalUsername')}
onChangeText={text => this.setState({payPalMeUsername: text})}
returnKeyType="done"
hasError={this.state.payPalMeUsernameError}
errorText={this.state.payPalMeUsernameError ? this.props.translate('addPayPalMePage.formatError') : ''}

Copy link
Member

Choose a reason for hiding this comment

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

We can remove this empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -92,6 +114,9 @@ class AddPayPalMePage extends React.Component {
placeholder={this.props.translate('addPayPalMePage.yourPayPalUsername')}
onChangeText={text => this.setState({payPalMeUsername: text})}
Copy link
Member

Choose a reason for hiding this comment

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

Please clear the error on the onChangeText

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@parasharrajat
Copy link
Member

@akshayasalvi Could you please add [HOLD] on the title?

@akshayasalvi akshayasalvi changed the title Paypal username field validation [Hold] Paypal username field validation Oct 14, 2021
@akshayasalvi
Copy link
Contributor Author

@parasharrajat @deetergp PR updated

* @returns {Boolean}
*/
function isValidPaypalUsername(paypalUsername) {
return paypalUsername && CONST.REGEX.PAYPAL_ME_USERNAME.test(paypalUsername);
Copy link
Member

Choose a reason for hiding this comment

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

A minor change as this condition does not always return boolean. when paypalUsername is ''.

If someone used this in JSX, It will crash the app. Better to convert paypalUsername in boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well thinking more about it, should I change it to:
!paypalUsername || CONST.REGEX.PAYPAL_ME_USERNAME.test(paypalUsername)

Current behavior to remove the username is deleting the content.

Copy link
Member

Choose a reason for hiding this comment

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

Well. I think @stitesExpensify can help here with it. Thanks for bringing this up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I don't think we should add the !paypalUsername since I'm adding a way to delete it right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment @stitesExpensify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@parasharrajat I've updated the Regex instead by changing * to +. Let me know if that's fine.

Copy link
Member

Choose a reason for hiding this comment

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

Yup. that's fine.

Copy link
Member

Choose a reason for hiding this comment

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

This one is remaining.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done now.

@akshayasalvi
Copy link
Contributor Author

@parasharrajat Any changes required in this PR?

parasharrajat
parasharrajat previously approved these changes Oct 18, 2021
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

LGTM. Tests well.

Ready for final review and possibly merge cc: @deetergp

Copy link
Contributor

@deetergp deetergp left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the changes. There was a merge conflict on the list of exports from src/libs/ValidationUtils.js which I resolved. It dismissed @parasharrajat's review, but since that export list is the only thing that changed since his last approval, I am going to go ahead and merge before we end up with another merge conflict.

Edit: There's also a [HOLD] on it. That needs to be removed before I can merge.

@akshayasalvi akshayasalvi changed the title [Hold] Paypal username field validation Paypal username field validation Oct 19, 2021
@akshayasalvi
Copy link
Contributor Author

@deetergp Thank you for resolving the conflict. The Hold was added for n6-hold and hence I've removed it from the title. Can we merge this?

@deetergp deetergp merged commit 33768ca into Expensify:main Oct 19, 2021
@OSBotify
Copy link
Contributor

✋ 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

🚀 Deployed to staging by @deetergp in version: 1.1.8-10 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.1.10-2 🚀

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

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.

5 participants