Sorry, I've been offline over the weekend. I don't know why AR is adding Validators, I think it's a remnant of the time when Validation was part of AR. Perhaps we just remove that part and see whether the tests still pass.
-Markus 2010/1/15 G. Richard Bellamy <rbell...@pteradigm.com>: > Markus, > > I know you've been busy with the release. Have you had a chance to think > about this? > > I have an edit to make my question more clear: > > "Can you think of a reason ActiveRecordModelBuilder is adding validators to > the model, when the model's validators collection isn't used during > validation?" > > -rb > > -----Original Message----- > From: G. Richard Bellamy [mailto:rbell...@pteradigm.com] > Sent: Wednesday, January 13, 2010 3:16 PM > To: castle-project-users@googlegroups.com > Subject: RE: NotSupportedException when ValidateGroupNotEmpty attribute is > used in ActiveRecord class > > Markus, > > Is there a particular reason ActiveRecordModelBuilder is adding validators > to the model, when those validators aren't then used during validation? The > reason I ask is that it's calling the Build() method of the > AbstractValidationAttribute, and that's what's throwing this exception. The > ValidateGroupNotEmpty attribute requires an instance, and Build() has no > access to that, and neither would ActiveRecordModelBuilder. > > Does the model builder ever need to concern itself with Validation > attributes? IIRC, NH Validation is a consumer of the model mappings, rather > than a part of the generation of those mappings, so it doesn't participate > in the mapping process either. > > Let me know if I'm way off base here. > > -rb > > > -----Original Message----- > From: castle-project-users@googlegroups.com > [mailto:castle-project-us...@googlegroups.com] On Behalf Of Bogdan Rogalski > Sent: Wednesday, January 13, 2010 10:03 AM > To: castle-project-users@googlegroups.com > Subject: NotSupportedException when ValidateGroupNotEmpty attribute is used > in ActiveRecord class > > Hi, > > when I use the 'ValidateGroupNotEmpty' attribute on a ActiveRecord class I > get this exception: > > System.NotSupportedException: You must call Build with a type parameter > > That's how my attribute looks like: > > [ValidateGroupNotEmpty("ProductOrTeam", "Select Product or Team")] > [BelongsTo("ProductId",NotNull=false)] > public Product Product > { > get { return product; } > set { product = value; } > } > > > The exception is not thrown when I use it in my model view class that is not > an ActiveRecord class. > > Any ideas how I can get ValidateGroupNotEmpty attribute to work on my > ActiveRecord classes as well? > > Thanks, > Bogdan Rogalski > > error source: > ActiveRecordStarter.Initialize(Assembly.Load("ProductWarehouse.Core"), > ActiveRecordSectionHandler.Instance); > > here is the partial stack trace: > [NotSupportedException: You must call Build with a type parameter] > Castle.Components.Validator.ValidateGroupNotEmptyAttribute.Build() +82 > > Castle.ActiveRecord.Framework.Internal.ActiveRecordModelBuilder.ProcessPrope > rties(Type > type, ActiveRecordModel model) +589 > > Castle.ActiveRecord.Framework.Internal.ActiveRecordModelBuilder.PopulateMode > l(ActiveRecordModel > model, Type type) +168 > > Castle.ActiveRecord.Framework.Internal.ActiveRecordModelBuilder.Create(Type > type) +255 > > > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to castle-project-us...@googlegroups.com. > To unsubscribe from this group, send email to > castle-project-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > > > >
-- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to castle-project-us...@googlegroups.com. To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.