I want my first check to verify email address uniqueness. If this validation fails, there''s no reason to go further with validating the user''s input. I want a singular message displayed in this case. Is there a way to do this? Also, what about group validations, such that, for example, if I have several checks on a password (existence, complexity, confirmation) and one fails, the others are ignored. So for instance, if the password field does not match its confirmation, I skip validating the password complexity. What''s the best approach to this? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Feb-14 10:16 UTC
Re: How to stop validating after a failed validation?
On Feb 13, 11:29 pm, ericindc <ericmilf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I want my first check to verify email address uniqueness. If this > validation fails, there''s no reason to go further with validating the > user''s input. I want a singular message displayed in this case. Is > there a way to do this?I think the best way would be to use your own function (instead of error_messages_for) for displaying the error. You might also be able to get somewhere with the :if option to validations (and have your if function check whether there are any errors yet). While the examples you provide are interesting, more generally it is really annoying as a user to have to correct form errors once at a time. Fred> > Also, what about group validations, such that, for example, if I have > several checks on a password (existence, complexity, confirmation) and > one fails, the others are ignored. So for instance, if the password > field does not match its confirmation, I skip validating the password > complexity. > > What''s the best approach to this? Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the response. I''m still not sure how I''ll approach this. I''m going to spend a bit of time tinkering with the :if option, as well as creating my own validation function. I agree that it is annoying for the user to have to correct errors one at a time. But I''d imagine correcting a series of errors, just to finally realize that the email address has already been registered, might be equally as annoying. Hence why I want the email uniqueness check to be first and foremost. If their email address has been used, the rest of the validation errors become moot. On Feb 14, 5:16 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 13, 11:29 pm, ericindc <ericmilf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I want my first check to verify email address uniqueness. If this > > validation fails, there''s no reason to go further with validating the > > user''s input. I want a singular message displayed in this case. Is > > there a way to do this? > > I think the best way would be to use your own function (instead of > error_messages_for) for displaying the error. You might also be able > to get somewhere with the :if option to validations (and have your if > function check whether there are any errors yet). While the examples > you provide are interesting, more generally it is really annoying as a > user to have to correct form errors once at a time. > > Fred > > > > > Also, what about group validations, such that, for example, if I have > > several checks on a password (existence, complexity, confirmation) and > > one fails, the others are ignored. So for instance, if the password > > field does not match its confirmation, I skip validating the password > > complexity. > > > What''s the best approach to this? Thanks. > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---