Prestaul / skeemas

JSON Schema validation
MIT License
11 stars 2 forks source link

"email" format validation rejects valid e-mail addresses #1

Closed daehlith closed 9 years ago

daehlith commented 9 years ago

The regular expression used by skeemas to validate strings with the "email" format attribute reject various valid e-mail address if the top-level domain suffix exceeds 4 characters. While those suffixes are rare, they do exist, and as such this case should be handled correctly.

An example of a valid e-mail address that currently fails validation would be contact@louvre.museum

Prestaul commented 9 years ago

@daehlith, I knew this issue was going to come up at some point. :stuck_out_tongue:

I had to choose between being very liberal and ensuring that I accepted all possible email addresses including some that were invalid, or being more selective and possibly excluding some valid (but almost never seen) email addresses. As mentioned here, I could match .museum but

This regex will match john@mail.office. It's far more likely that John forgot to type in the .com top level domain rather than having just created a new .office top level domain...

Maybe I should have gone for the more liberal regular expression... Maybe I should just allow any TLD over 2 chars long? What do you think?

daehlith commented 9 years ago

If it is necessary to verify the correctness of an e-mail address than that cannot be achieved using a syntactical validation of said e-mail address. As such I'd suggest to simply accept everything that looks like a syntactically valid e-mail address as per RFC 5322, and delegate the responsibility of verification to a different level than the JSON schema validation.

Prestaul commented 9 years ago

@daehlith, thanks for the report and the feedback. I've published a much more liberal version of the email validation in version 1.2.0