Luca Roma wrote:
> hi, i have a model with 2 validations on a field
> 
> example:
> 
>   validates_presence_of     :email
>   validates_length_of       :email,    :within => 6..100 #[email protected]
>   validates_uniqueness_of   :email
>   validates_format_of       :email,    :with =>
> Authentication.email_regex
> 
> 
> if i do the submit of form for a new object of the model with a blank
> mail
> i receive 4 errors.
> In this case i want receive only the errore for:
>   validates_presence_of     :email
> 
> is possible?
> 
> thanks

Add  , :if => Proc.new { |user| !user.email.blank? } in other validation 
except validates_presence_of :email

like
 validates_uniqueness_of  (:email,:if => Proc.new { |user| 
!user.email.blank? })
-- 
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 [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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to