# Accessing an ActiveRecord object's validation list

**URL:** <https://www.ruby-forum.com/t/accessing-an-activerecord-objects-validation-list/83812>\
**Category:** Ruby\
**Created:** [January 29, 2007, 10:54pm UTC](https://www.ruby-forum.com/t/accessing-an-activerecord-objects-validation-list/83812 "2007-01-29T22:54:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Cowden](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Michael\_Cowden](https://www.ruby-forum.com/u/Michael_Cowden)\
**Post date:** [January 29, 2007, 10:54pm UTC](https://www.ruby-forum.com/t/accessing-an-activerecord-objects-validation-list/83812/1 "2007-01-29T22:54:52Z")

</div>

Is there a way to access an ActiveRecord object’s validation list?  
for instance:

u = User.find 1  
u.attributes.each { |attr| puts attr if u.validates\_presence\_of?(attr) }

I’m building a test\_scaffold generator and I want to access the list of  
validations for a model so that I can build the appropriate tests.

Thanks,

-Michael Cowden  
[StoryRight.com](http://StoryRight.com)  
removed\_email\_address@domain.invalid  
(443) 519-8662
