-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
IsEmail validates non RFC compliant #908
Comments
You can use the option require_tld and each of your cases passes. Here is an example: 'use strict';
const validator = require('validator');
const validate = [
'admin@admin',
'admin@admin.x',
'admin@admin.de2'
];
validate.forEach(email => {
const isEmail = validator.isEmail(email, {
require_tld: false
});
console.log(email + ': ' + isEmail); // Each email passes
}); Output: admin@admin: true
admin@admin.x: true
admin@admin.de2: true |
Ok, it actually doesn't solve the problem, but that lies in sequelize. Apart from that, I think it would be better that the default case is RFC compliant and not non compliant. |
This solution only works for the e-mails provided by @DerKnerd but e-mails from google with username part that has a length less than six don't work. And the bug is here
would be good if you could fix this or I can submit a Pull Request |
But is still a valid email address, the name of the function is misleading, cause it does vendor specific checks. |
It doesn't do vendor specific checks unless you specify the option I don't feel the function is misleading at all, it is well documented and works great. |
Ok, I didn't see that part in the code. But still it doesn't work great, it is wrong in the default case. The RFCs very clearly defines how a valid email address should look like. Here is an article explaining it very thourgly https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/ Here are all relevnt RFCs:
So no,it doesn't work great. It works against the standards at least in the default case and this case should never represent something different than the standards. |
@justinkalland you right google username minimum length is 6 but as @DerKnerd said you are doing vendor specific specif checks (https://github.com/chriso/validator.js/blob/master/src/lib/isEmail.js#L45) I tested without setting the option |
The latest version of the library does not do domain-specific validation by default (it did at one point, but that was removed; see #873). As for requiring a TLD, the validator tries to balance strict RFC validation with the fact that users expect emails to be a certain way in almost all cases. We have the same issue with The TLD validator, enabled by default, requires at least two characters in the TLD, and does not allow numbers. Your example email hostnames |
Sidenote: We might need to revisit this; that's minor though. |
@chriso for me this answer is fairly simple. The default case is to comply with the RFC because the internet is build on standards. It would probably be good idea to allow developers to also ask for a tld, but that shouldn't be the default case. I think it is not hard at all, just implement the RFC as the default case, and allow more restrictions by the developer. My "home" is business development, and the Exchange Server by Microsoft allows nearly everything RFC compliant as an email address so the use cases are there out in the business world. @profnandaa I know that even the w3c said the requirements by the RFC are to strict and browser implement a way simpler RegEx. But that doesn't change the fact, that it is more allowing than the validation of validator.js. This behavior causes problems in node.js environments, cause the browser says it is valid, but the server says it is not even though it is. |
Thanks for the perspective, but I think we'll stick with the current behavior. Strict RFC validation is a non-goal of the library, and relaxing the current defaults would cause more issues than it would solve. |
My gripe with this is - foo@bar.com is valid but foo@gmail.com is not. |
We are using sequelize which uses this library for email validation. Currently we experiencing the issue, that the valid email addresses we provide are taken as invalid. A few examples:
And probably more. Can you please fix that, it causes major issues in business use cases, cause local domain addresses with no tld, a number in the tld or just one character in the tld are very common.
The text was updated successfully, but these errors were encountered: