I tried using "email@nodomain" as an email, which should be rejected due to invalid email format. But, is accepting the input.
Describe your issue here, include schemas and inputs you are validating if needed.
const schema = Joi.object().keys({
email: Joi.string().email().required(),
});
On trying "email@nodomain" accepts the string input as an email. Whereas it must reject it since the domain is invalid.
The correct regex for email must be
/^([a-zA-Z0-9_-.]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]{2,5})$ /
This would allow only "[email protected]" or such type of strings to pass as email.
Nope, it's a valid email. Read the options and search issues about minDomainAtoms.
The above issue is still not fixed on [email protected], could this be fixed with correct regex in any of the versions coming up
Have you at least read the response I gave ?
I can understand in a way regarding minDomainAtoms but would it not be more sensible to cater to the majority of use cases where we'd expect this by default to be set to 2?
But isemail isn't about catering to specific use-cases. It is geared toward following the RFCs that dictate what is and isn't a valid email. So the defaults are to follow the RFCs as closely as possible. Options like minDomainAtoms are added on top of the RFCs to allow people to limit emails to be more restrictive than RFC.
Hmm I agree, think I'm coming from the angle of it not being super obvious at a glance and a documentation tweak should hopefully prevent some confusion.
I've submitted a PR for an update to the README.md
Most helpful comment
Have you at least read the response I gave ?