Validate email address

What is the best way to validate an email address?

I have been unable to fnd a validates_email address method which seems a
bit strange for rails

josh wrote:

What is the best way to validate an email address?

I have been unable to fnd a validates_email address method which seems a
bit strange for rails

i use this:
validates_format_of :email,
:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i

david wrote:

josh wrote:

What is the best way to validate an email address?

I have been unable to fnd a validates_email address method which seems a
bit strange for rails

i use this:
validates_format_of :email,
:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i

thanks that seems to ahve worked fine.
Althrough it seems a bit strange how rails does not have this in the lib

Hi –

On 3/26/07, josh [email protected] wrote:

                  :with =>

/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i

thanks that seems to ahve worked fine.
Althrough it seems a bit strange how rails does not have this in the lib

If Rails were to have an email address validator, it would have to
cover all of RFC 2822, which this regex doesn’t.

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

On Mar 26, 1:58 pm, “David A. Black” [email protected] wrote:

I have been unable to fnd a validates_email address method which seems a
If Rails were to have an email address validator, it would have to
cover all of RFC 2822, which this regex doesn’t.

I know the book “Master Regular Expressions” by Jeffrey E.F. Friedl
includes an example to parse an email address that is 6598 bytes long
(see Appendix B). And I remember reading that it didn’t handle all
possible nesting cases.

I’ve been using this plugin:

http://agilewebdevelopment.com/plugins/validates_email_format_of

Wes