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: 1. validates_numericy --> depends on ActiveRecords'' before_type_case 2. The exceptions were from the ActiveRecord namespace 3. 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? -- Posted via http://www.ruby-forum.com/.
C''omon, someone has to either agree with this, or be able to say what''s bad about it? List Recv wrote:> 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: > > 1. validates_numericy --> depends on ActiveRecords'' before_type_case > 2. The exceptions were from the ActiveRecord namespace > 3. 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?-- Posted via http://www.ruby-forum.com/.
On 1/16/06, List Recv <listrecv@gmail.com> wrote:> C''omon, someone has to either agree with this, or be able to say what''s > bad about it?http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/validations.rb It''s been like that for awhile now. -- rick http://techno-weenie.net
List Recv wrote: C''omon, someone has to either agree with this, or be able to say what''s bad about it? It would be useful to me to have validations decoupled from ActiveRecord. List Recv wrote: 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: 1. validates_numericy --> depends on ActiveRecords'' before_type_case 2. The exceptions were from the ActiveRecord namespace 3. 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? -- Jack Christensen jackc-/SOt/BrQZzOj3I+7jmQ39gC/G2K4zDHf@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This would be VERY usefull for a project I''m working on. I''ve cloned the interface to active record objects, and use a different data storage scheme. Right now I''m on my own for data validation functionality. If I could mixin all the existing validation stuff, that would save a bunch of work. I''m all for it. matt On 1/15/06, List Recv <listrecv@gmail.com> wrote:> > 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: > > 1. validates_numericy --> depends on ActiveRecords'' before_type_case > 2. The exceptions were from the ActiveRecord namespace > 3. 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? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060116/4611ad7d/attachment.html
> What does everyone say? Would this be a good change? Is there an > important reason for *not* doing this?I also think that this is a good idea and would be interested in hearing if anyone thinks it is not good. I would even go so far as to put validations in their own package. Perhaps ActiveValidations. Validations are something that a lot of applications can benefit from. Sa?a Ebach
This would also be helpful for the folks talking about attempting to specify the schema in the model (the migrations/schema thread and the using Og in rails thread). b List Recv wrote:> C''omon, someone has to either agree with this, or be able to say what''s > bad about it? > > List Recv wrote: > >>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: >> >>1. validates_numericy --> depends on ActiveRecords'' before_type_case >>2. The exceptions were from the ActiveRecord namespace >>3. 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? > > >