email validation

im back again..

ive been linked to http://tfletcher.com/lib/rfc822.rb to use for e-mail
validation, can someone explain how I use it with a validation
statement?

right now i have validates_format_of :email, :with =>

but im not sure how to incorporate it properly..

thanks again!

use the email_column plugin!

It uses tmail::address for most of its lower level stuff and, as far as I
can tell, this is part of the ruby action mailer.

In your model:

include EmailColumn
email_column :email

and it takes care of the validation

cool, works like a charm.. this is the one I was using, I converted it

validates_format_of :email, :with =>
%r{^(?:[_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-zA-Z0-9\-\.]+)*(\.[a-z]{2,4})$}i

I havent had any problems with it when it was PHP so im sure it will be
perfect for most people.. let me know if you know of something im
forgetting in that regex and ill change it as needed.

validates_format_of :email, :with =>
%r{^(?:[_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-zA-Z0-9\-\.]+)*(\.[a-z]{2,4})$}i

I'm pretty sure that is incorrect. Check out:
http://www.norid.no/domenenavnbaser/domreg.html

Plus I believe there are military domains that are one character, like
'z' for the New Zealand military?

this one actually really fries me. SO many sites don't allow me to
enter something like temp.email@user.domain.coop

they completly crap out...sometimes it is the period before the '@', or
two periods after the '@', and then the '.coop' usually throws most
people for a loop.

do people a favor and keep this validation loose unless you *really*
need to check it. Do you care if the domain is between 2-4 chars?

Adam

I agree. Check that it has an @ and at least one period somewhere
after the @, but don't waste any more time on it than that.
I don't really see why extensive email validation is necessary. The
only reason I can think of is to stop people entering stuff which
isn't a real email address, but of course, that won't work, because,
because someone could quite easily enter dgfhfkar4t463@gjefinpwhb.com,
which appears perfectly valid to any email validator regexp. So just
leave it out... it's pointless, and you risk excluding legitimate
email addresses.
-Nathan

There is a really nice (and long) regex here that I've used in the past.

http://www.regular-expressions.info/email.html

Robby

Hello,

Have you checked validates_as_email plugin:

https://svn.greenpeace.org/repositories/rails_plugins/validates_as_email/trunk/README

It looks quite easy to use. Personally I am having trouble installing
it. If anybody have an idea:

ruby script/plugin install
https://svn.greenpeace.org/repositories/rails_plugins/validates_as_email
c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect': certificate verify
failed (OpenSSL::SSL
::SSLError)
        from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect'
        from c:/ruby/lib/ruby/1.8/net/http.rb:555:in `do_start'
        from c:/ruby/lib/ruby/1.8/net/http.rb:544:in `start'
        from c:/ruby/lib/ruby/1.8/open-uri.rb:245:in `open_http'
        from c:/ruby/lib/ruby/1.8/open-uri.rb:629:in `buffer_open'
        from c:/ruby/lib/ruby/1.8/open-uri.rb:167:in `open_loop'
        from c:/ruby/lib/ruby/1.8/open-uri.rb:165:in `open_loop'
        from c:/ruby/lib/ruby/1.8/open-uri.rb:135:in `open_uri'
         ... 11 levels...
        from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/plugin.rb:871
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/depende
ncies.rb:147:in `require'
        from script/plugin:3

I have been playing around with soap4r so it could come from there.
Did not have time to really look into it but somebody out there might
know the answer,

Cheers,
Carl