Hi to all,
i''d like to insert a validation inside my model about a mac address
field.
I''ve used this sintax but it''s not working.
validates_format_of :mac_address, :with =>
/^((?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9]))$/i,
                                          :on => :create,
                                          :on => :update,
                                          :message => "MAC ADDRESS
incorrect"
this code it''s not working, i''m looking for a solution but i
can''t find
out the problem...
Any help will be great...
Thanks
Andre
-- 
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
-~----------~----~----~----~------~----~------~--~---
On Jan 18, 2008 3:03 PM, Andrea Campagna <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi to all, > > i''d like to insert a validation inside my model about a mac address > field. > I''ve used this sintax but it''s not working. > > validates_format_of :mac_address, :with => > /^((?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9])+(?:[-a-f0-9]))$/i, > :on => :create, > :on => :update, > :message => "MAC ADDRESS > incorrect" > > this code it''s not working, i''m looking for a solution but i can''t find > out the problem... > > Any help will be great...Try with this regexp: /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i irb(main):001:0> ''00:09:6B:DF:FE:42'' =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i => 0 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Emilio Tagua wrote:> irb(main):001:0> ''00:09:6B:DF:FE:42'' =~ > /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i > => 0Hi Emilio, thanks too much... It works ;) -- 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 -~----------~----~----~----~------~----~------~--~---