Forum: Ruby on Rails How to stop validating after a failed validation?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric M. (Guest)
on 2009-02-14 01:31
(Received via mailing list)
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.
Frederick C. (Guest)
on 2009-02-14 12:17
(Received via mailing list)
On Feb 13, 11:29 pm, ericindc <removed_email_address@domain.invalid> 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
Eric M. (Guest)
on 2009-02-14 14:16
(Received via mailing list)
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 C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.