# Validation levels

**URL:** <https://www.ruby-forum.com/t/validation-levels/158489>\
**Category:** Rails\
**Created:** [January 23, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/validation-levels/158489 "2009-01-23T21:25:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andywatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@andywatts](https://www.ruby-forum.com/u/andywatts)\
**Post date:** [January 23, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/validation-levels/158489/1 "2009-01-23T21:25:09Z")

</div>

Sometimes I want to show just one error, even when a field fails two or  
three validations.

A custom validation method is easy enough, but the helpers are nice and  
concise.  
So, has anyone found a way of doing this with AR’s validation helpers?  
The :if/:unless look promising, but its made harder by validations being  
applied in a random order.

- Andy

P.s. The validatable gem has the excellent ‘level’ option on it’s  
validation helpers. [http://validatable.rubyforge.org/](http://validatable.rubyforge.org/)  
“Validations can be given levels. If a validation fails on a level the  
validations for subsequent levels will not be executed.”

---

<div class="post-metadata">

**Author:** ![andywatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@andywatts](https://www.ruby-forum.com/u/andywatts)\
**Post date:** [January 24, 2009, 1:41am UTC](https://www.ruby-forum.com/t/validation-levels/158489/2 "2009-01-24T01:41:51Z")

</div>

Often I just show the first element in the error\_messages array unless  
that array is nil

On Jan 24, 7:25 am, Andy W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
