guillaumepotier / Parsley.js

Validate your forms, frontend, without writing a single line of javascript
http://parsleyjs.org
MIT License
9.04k stars 1.31k forks source link

email validation should allow "admin@domain" format #896

Open kromit opened 9 years ago

kromit commented 9 years ago

Hi, i am not sure if its validator.js problem since it is out of date here, but the test for the email here also seems to be too simple.

marcandre commented 9 years ago

Not sure what yo mean; "admin@domain" is not a valid email, as "domain" is not a valid domain part

Not quite sure what you mean by validator.js not being the latest, because it comes bundled with parsley, so if you have the latest parsley, you should have the latest version (or very recent).

How about reporting your version of validator.js/parsley.js?

kromit commented 9 years ago

I am on mobile and will add the links later.

"domain" IS a valid domain part according to the RFC and the wiki link (admin@mailserver1).

I believe I've seen a validator 1.0.0 dependency in the bower file.

guillaumepotier commented 9 years ago

Hi,

Even if admin@domain is in the RFC, it feels very buggy to allow that in parsley. How many emails follow that pattern really?

About validator.js parsley does not unnecessary need to be up to date, it evolves at its own pace with other concerns, and bw 1.0.0 and 1.1.1 if I recall clearly (on mobile too) there is it much interesting for Parsley.

kromit commented 9 years ago

Even if admin@domain is in the RFC, it feels very buggy to allow that in parsley. How many emails follow that pattern really?

In the Internet almost none, but it is common in intranet environment to omit the TLD. Denying this format would render this framework less useful for intranet applications.

btw.: I've looked into the code and it seems that the validator.js is asked for email validation so i guess this issue does not apply to parsley but to validator.js

marcandre commented 9 years ago

I'm sorry, I was completely wrong. No idea how I managed to double check and not get it right.

So, after getting my facts straight and checking that Chrome / Safari / etc. also accept "admin@domain" in their HTML5 validations, I have to side with @kromit, at the very least for type="email". @guillaumepotier: do you want to introduce a difference for data-parsley-type="email"? That's up to you, but I think we really should aim to be compatible with HTML5 for the validations we replace, like type="email". I'd keep it simple and do the same for data-parsley-type="email", but that's much more of a debatable choice...

marcandre commented 9 years ago

@guillaumepotier: ping... type="email" should accept "admin@domain" 1) data-parsley-type="email" accepts it too 1b) and `data-parsley-type="extranet-email" doesn't accept it 2) data-parsley-type="email" doesn't accept it

guillaumepotier commented 9 years ago

Sorry for the late answer,

I think Parsley should stick to HTML5 validation. Let's allow this kind of email if Regex not too hard to change and let's see if ppl would need such a extranet-email or email-strict whatever validator (not sure).

OlivierCuyp commented 7 years ago

Hi guys,

Is there a way now to specify which email validation you desire ?

Here is my concern, the actual version allows accents which is right according the latest RFCs (https://en.wikipedia.org/wiki/Email_address#Internationalization). But which is also almost not supported, like Google doesn't allow you to create this kind of email addresses (https://en.wikipedia.org/wiki/Email_address#Internationalization_support).

So I would like to restrict to ASCII characters, is there a way to do this ?

PS: Email validation is always a trouble maker ;)

marcandre commented 7 years ago

Currently, only the official validation. It's probably easy to disallow accents by adding an extra pattern validator. It could be nice to have a stricter type to disallow admin@domain though. Note that google does sent to email addresses with accents.

luxcan commented 7 years ago

Hi guys,

Should the email validator be following the regular expression below as stated in w3c (https://www.w3.org/TR/2012/WD-html-markup-20120315/input.email.html)?

/^[a-zA-Z0-9.!#$%&’+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)$/

marcandre commented 7 years ago

Mmm, indeed Chrome/Safari follow that spec and won't allow accents in an email field, so we should follow the convention, at least for type=email.