Property Business Rule Validator...

Topics: Building and extending application blocks, Validation Application Block
Aug 4, 2008 at 4:55 PM
I'm currently using the Enterprise Library 4.0 in my ASP.Net application utilizing the PropertyProxyValidator and the built-in Validators in my business object.  However, I found a need to extend the existing validators because I need to access other properties of the object.  Yes, I tried the Self-Validation Validator and it works.  However, this runs every time I call Validate and in my case every property change (I have logic in business object that validates the property when it changes) which in my eyes is kind of inefficient.  So, I built a BusinessRuleValidator and BusinessRuleValidatorAttribute, which calls a specified method.  However, when calling the business method during the DoValidate method, the objectToValidate parameter supplied is the property value not the object is self.

Is this possible to do?  If so, can you point me in the right direction...
Aug 4, 2008 at 10:49 PM
Hi,

When you're using the PropertyProxyValidator with ASP.NET apps, you're really applying the validation logic specified for properties in a CLR type's properties to the values of ASP.NET controls in your page; no instances of the CLR type are involved (even when a property comparison validation is specified.) This rules out self validation, or any validation that requieres an instance of the validated type.

If all the information you need to validate is available in ASP.NET controls, you could use an approach similar to the one used by the PropertyComparisonValidator.

Hope this helps,
Fernando
Aug 5, 2008 at 1:00 PM

Thanks for the reply.  After submitting the post, I realized the PropertyProxyValidator was just validating the control and not the object.  Your explanation makes sense.

Thanks again.

Mark