Should Rails be able to validate email out of the box?

Wholeheartedly agree here, I would personally never build an email validator that doesn’t accept + tags (or any other similarly reasonable syntax of tags for that matter)

1 Like

I think the HTML5 definition strikes a good balance between specifications and actual use.

https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email):willful-violation

This requirement is a willful violation of RFC 5322, which defines a syntax for e-mail addresses that is simultaneously too strict (before the “@” character), too vague (after the “@” character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here.

In general, it is the policy of the HTML working group that when real-world implementations (of browsers, mostly) and formal specs differ, they tend to follow the former (or at least acknowledge the real-world implementations, so the HTML spec will not be backwards incompatible with already released browsers). I think this is a sound approach.

If you disagree with the HTML5 definition, you can use your own regexp instead. But as a default, I think it is uncontroversial for a web-application framework to follow the definition provided in the HTML5 specification and implemented in (I assume) most browsers.

4 Likes