mentorship-flutter icon indicating copy to clipboard operation
mentorship-flutter copied to clipboard

Added regex based email validation

Open KevalPrajapati opened this issue 3 years ago • 12 comments

Description

Added regex email validation. Fixes #149

Flutter Channel:

  • [X] I have used the Flutter Beta channel on my local machine

Type of Change:

Delete irrelevant options.

  • Code

Code/Quality Assurance Only

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

The following cases are tested *Following are invalid cases

  • Missing @ sign and domain
  • Missing username
  • Two @ sign
  • Leading or trailing dot in address
  • And other invalid emails

invalid email invalid

valid email valid

Checklist:

Delete irrelevant options.

  • [X] My PR follows the style guidelines of this project
  • [X] I have performed a self-review of my own code or materials

Code/Quality Assurance Only

  • [X] My changes generate no new warnings

KevalPrajapati avatar Jan 16 '21 09:01 KevalPrajapati

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

techno-disaster avatar Jan 16 '21 16:01 techno-disaster

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

I was thinking to do the same. But as the app earlier didn't work like that so didn't do that. I am on it.

KevalPrajapati avatar Jan 16 '21 18:01 KevalPrajapati

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

Also @Techno-Disaster Do we need a password validator? If yes then what are the conditions? We need to know what passwords are valid in backend.

KevalPrajapati avatar Jan 16 '21 19:01 KevalPrajapati

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

Also @Techno-Disaster Do we need a password validator? If yes then what are the conditions? We need to know what passwords are valid in backend.

afaik we already have some validation on the backend. But it would be nice if users are given this warning as before they hit the signup button

{'message': 'The username field has to be longer than 5 characters and shorter than 25 characters.'} {'message': 'The password field has to be longer than 8 characters and shorter than 64 characters.'} {'message': "Password shouldn't contain spaces."} {'message': 'Your email is invalid.'}

techno-disaster avatar Jan 16 '21 19:01 techno-disaster

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

Are you sure we should use a library for this? I have anyways implemented the code with library.. But I thought should we depend on a library for this or not. What do you say @Techno-Disaster ?

KevalPrajapati avatar Jan 16 '21 20:01 KevalPrajapati

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

Are you sure we should use a library for this? I have anyways implemented the code with library.. But I thought should we depend on a library for this or not. What do you say @Techno-Disaster ?

imho yes, the code looks cleaner and sometimes it is possible that we miss some regex. Another subtle point could be libraries update and we won't have to update our manually written regex everytime we found iut something is missing in it. The email_validator library on pub has the most correct implementation afaik. (ik it's a really insignificant change but my main point is code looks cleaner with email.validate() instead of some complex regex)

@isabelcosta what do you think about this?

techno-disaster avatar Jan 16 '21 21:01 techno-disaster

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

For the alert message every field would need form of itself. Should I do that?

KevalPrajapati avatar Jan 17 '21 06:01 KevalPrajapati

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

For the alert message every field would need form of itself. Should I do that?

Can you explain what you mean by form of itself?

techno-disaster avatar Jan 17 '21 15:01 techno-disaster

@KevalPrajapati Just to keep the clone clean, could you use a library from pub.dev to validate? Also can you add a alert message below the textfield itself once the user finishes editing the email textfield

For the alert message every field would need form of itself. Should I do that?

Can you explain what you mean by form of itself?

So when you click the submit button, the form is first being validated and then the registration process is being done. When you validate a form, all the fields inside a form are validated.

So if we want to validate individual fields when user inputs something in it, we would need to put every field in a unique form so when the user inputs some thing in it, the form can be validated.

Currently I am traveling so tomorrow I will show you the code.

KevalPrajapati avatar Jan 17 '21 16:01 KevalPrajapati

@Techno-Disaster I have implemented email_validator library and added alert messages. Screenshot

KevalPrajapati avatar Jan 19 '21 05:01 KevalPrajapati

@Techno-Disaster sorry for rushing a bit. But could you check the updated pr please.

KevalPrajapati avatar Jan 25 '21 05:01 KevalPrajapati

LGTM, thank you for contributing to mentorship flutter

techno-disaster avatar Jan 25 '21 11:01 techno-disaster