It seems to me that Validations are quite useful for many objects, even
ones having nothing to do with ActiveRecord.
Common examples are Contact Us forms, multi-step forms, web service
paramater validations, etc.
I took a look at the source for Validations, and it seems that it is
very independent from ActiveRecord. I caught only three depenedencies:
- validates_numericy --> depends on ActiveRecords’ before_type_case
- The exceptions were from the ActiveRecord namespace
- Including Validations hooked on methods like save
It would seem to me that Validations would be best off as an independent
mixin. All ActiveRecord would need to do is mix it, add
validates_numericay (1), catch the exceptions and rethrow them as
ActiveRecord exceptions (2), and hook save type methods (3).
What does everyone say? Would this be a good change? Is there an
important reason for not doing this?