Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Added regex based email validation #152

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

KevalPrajapati
Copy link

Description

Added regex email validation.
Fixes #149

Flutter Channel:

  • 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.

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

Code/Quality Assurance Only

  • My changes generate no new warnings

@techno-disaster
Copy link
Contributor

@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

@KevalPrajapati
Copy link
Author

@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
Copy link
Author

@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.

@techno-disaster
Copy link
Contributor

@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.'}

@KevalPrajapati
Copy link
Author

@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 ?

@techno-disaster
Copy link
Contributor

@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?

@KevalPrajapati
Copy link
Author

@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?

@techno-disaster
Copy link
Contributor

@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?

@KevalPrajapati
Copy link
Author

@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
Copy link
Author

@techno-disaster I have implemented email_validator library and added alert messages.
Screenshot

bartekpacia
bartekpacia previously approved these changes Jan 20, 2021
}

String _validateConfirmPassword(String value) {
if (value.toString() != _passwordController.text) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@KevalPrajapati Can you remove tge #153 parts ? Lets keep it open for first timers for now

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@KevalPrajapati
Copy link
Author

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

@techno-disaster
Copy link
Contributor

LGTM, thank you for contributing to mentorship flutter

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

Successfully merging this pull request may close these issues.

Regex Based Validation for Email and Password during Registration
3 participants