+1 Both to including validates_as_email in core and that that regex is a
joke.
Ben
On 2/11/11 10:38 AM, Rodrigo Rosenfeld Rosas wrote:
Em 11-02-2011 15:20, Rainer Frey escreveu:
...
Similar cases can be made for URLs.
So yes, the fomat of email addresses and URLs may be quite different
in different applications.
That doesn't mean that a gem should come first. DDH became famous among
other things for his "opinated software" policy. By the way, I've been
enjoyed a lot his recent book "Rework", although I've not finished it
yet. Highly recommended. As well as José Valim's excellent book
"Crafting Rails Application".
Back to the subject, after the free merchandise, what I'm saying is that
this is a very common requirement and most developers don't (shouldn't?)
care that much about e-mail format. At least for 90% of the
applications. So, I don't see any reasons why not to include some
"validates_email_of" helper. It doesn't need to solve all cases. It can
have some options for specifying some regular expression or some lambda
for verifying the e-mail format in case someone is really worried about
it. It can even be customized in a global configuration per
project/engine/mountable application. There could be some pre-defined
options specified by symbol like :rfc_compliant,
:performant_verification, etc.
I just don't buy the idea to make this more difficult than it should be.
It is much simpler to evolute and understand better the validations
after they are provided on rails core distribution. Also, in the
beginning, there were lots of philosophies about Rails, like the 80/20
principle. No body talks about this anymore... In every web application
with a user sign up feature, there will be an e-mail validation. This is
probably over 90% of the web applications built with Rails. Even so,
this will require all of these developers to replicate the logic to
validate e-mail. Most of them will just extract this one from Rails
documentation:
validates_format_of :email, :with =>
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
That is because, this is usually the first thing written in a new
application that requires a user to log in. In this stage, no one is
willing to invest any time on the e-mail validation rule. Usually this
will only happen if some customer complaint about not being able to
register himself because the system is rejecting his e-mail.
For my applications, I usually don't care very much about the format
because of the way I handle the registration part. The user doesn't
input any information in the register form, except his e-mail address.
Then, he is informed that there were sent instructions for continuing
the register process to his e-mail and he'll continue to register
following a link on the e-mail. That way I can know for sure that the
e-mail is valid.
So, I think that even if not perfect, Rails should not wait for any gem
before supporting e-mail and URL validations built-in, even though I
have a feeling that it won't happen based on what I've being observed
from the core-team point of view.
Best regards,
Rodrigo.
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.