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.ProcessProperties(Type
type, ActiveRecordModel model) +589
Castle.ActiveRecord.Framework.Internal.ActiveRecordModelBuilder.PopulateModel(ActiveRecordModel
model, Type type) +168
Castle.ActiveRecord.Framework.Internal.ActiveRecordModelBuilder.Create(Type
type) +255
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
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
-Markus
2010/1/15 G. Richard Bellamy <rbel...@pteradigm.com>:
> --
> 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-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
>
>
>
>