The validation reflection plugin adds three things
(1) Reflective access to validations
- ModelClass.reflect_on_all_validations
- ModelClass.reflect_on_validations_for(:property)
(2) It provides “declarative” methods for defining
validations based on database metadata
- validates_presence_of_mandatory_content_columns
- validates_lengths_of_string_attributes
- validates_all_associated
(3) It reflects validation information into the class attributes of
of HTML elements generated from rhtml templates.
See test/instance_tag_validations_test.rb for what this looks like.
Yes, for validates_format_of it gets nasty.
Thanks. I had the functionality lying around for more than a year as
part of my BoilerPlate project. But as that project is all but dead, I
intend to release some of its reusable functionality in the form of
plugins.
It is, unfortunately, based on an earlier version of Prototype and my
own support code probably clashes with current the Prototype lib. I
intend to rectify this some time and bundle the stuff in a plugin.
Alas, I don’t have the time right now to do it right.