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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 railsi use this: validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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,})$/ithanks that seems to ahve worked fine. Althrough it seems a bit strange how rails does not have this in the lib -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On 3/26/07, josh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 libIf 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) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 26, 1:58 pm, "David A. Black" <dbl...-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org> wrote:> Hi -- > > On 3/26/07, josh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > 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 > > 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve been using this plugin: http://agilewebdevelopment.com/plugins/validates_email_format_of Wes On Mar 26, 11:09 am, josh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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 > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---