Is it possible to use the selfvalidation attribute with my validations located in a metadatatype? I'm using Enterprise Library 5's Validation Application Block.
A:
As I explained in my other answer, this isn't supported out of the box. However, this can be achieved by hooking into the framework using depedency injection and replace the existing AttributeValidatorFactory
implementation. I written a post on my weblog on how to do this: Mixing Validation Application Block With DataAnnotation: What About SelfValidation?
I hope this helps.
Steven
2010-09-12 17:59:03
Thank you Steven for such a detailed response; it worked great! My biggest concern was keeping our business logic and validation separate and was a little disappointed when I thought I'd have to move it all back into the instance class. Also, I wasn't aware that I could inject types into EL using Unity; I'm grateful you showed me that.
Scott Williams
2010-09-13 14:38:52
@Scott: Unity is just the default IoC container for EntLib. In fact you can use any container you like.
Steven
2010-09-13 15:38:01