# Reading AR validations at runtime

**URL:** <https://www.ruby-forum.com/t/reading-ar-validations-at-runtime/172123>\
**Category:** Rails\
**Created:** [July 15, 2009, 8:09am UTC](https://www.ruby-forum.com/t/reading-ar-validations-at-runtime/172123 "2009-07-15T08:09:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [July 15, 2009, 8:09am UTC](https://www.ruby-forum.com/t/reading-ar-validations-at-runtime/172123/1 "2009-07-15T08:09:31Z")

</div>

Does anyone, by chance, know how to obtain a list of all the defined  
activerecord validations at runtime?

In other words, I’d like to query a model for all the fields that are  
unique, or required.

I found this: read\_inheritable\_attribute(:validate), but it seems to be  
deprecated in later versions of rails. Thanks so much for any insight.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [July 15, 2009, 2:26pm UTC](https://www.ruby-forum.com/t/reading-ar-validations-at-runtime/172123/2 "2009-07-15T14:26:20Z")

</div>

On Wednesday 15 July 2009, Will Grundler wrote:

> Does anyone, by chance, know how to obtain a list of all the defined  
> activerecord validations at runtime?

[http://rubyforge.org/projects/valirefl/](http://rubyforge.org/projects/valirefl/)  
[http://github.com/mschuerig/validation\_reflection/tree/master](http://github.com/mschuerig/validation_reflection/tree/master)

HTH,  
Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [July 15, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/reading-ar-validations-at-runtime/172123/3 "2009-07-15T17:19:48Z")

</div>

Thanks Michael! That’s a big help.

Michael S. wrote:

> On Wednesday 15 July 2009, Will Grundler wrote:
> 
> > Does anyone, by chance, know how to obtain a list of all the defined  
> > activerecord validations at runtime?
> 
> [http://rubyforge.org/projects/valirefl/](http://rubyforge.org/projects/valirefl/)  
> [http://github.com/mschuerig/validation\_reflection/tree/master](http://github.com/mschuerig/validation_reflection/tree/master)
> 
> HTH,  
> Michael
> 
> –  
> Michael S.  
> [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Michael Schürig | Sentenced to making sense](http://www.schuerig.de/michael/)
