How do I create a custom validator that tests two properties at once?

Topics: Validation Application Block
Dec 6, 2008 at 2:25 PM
Hi

In my database, I have a composite unique key constraint (CustomerId, Name) on a entity. I want to test if the unique constraint is upheld before submitting to the database. The user can customize the Name attribute on the entity, so I would like to make a custom validator that validates the name property, but while doing it, I need access to the CustomerId property as well. How do I do that?

I an using WCSF, which means I am stuck in Entlib 3.1 and the included VAB.

Regards, Egil.
Dec 7, 2008 at 2:26 PM
Hi,

You can try using Self-Validation. See this link:
http://www.davidhayden.com/blog/dave/archive/2007/01/24/BusinessObjectValidationEnterpriseLibrary.aspx
http://msdn.microsoft.com/en-us/library/cc309328.aspx

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Dec 7, 2008 at 4:24 PM
Hi Valiant

I could not figure out how to get the PropertyProxyValidator control use the Self-Validation method, which is want I want. So I ended up extending PropertyProxyValidator, adding a new property named SateliteData and getting the desired result.

Dec 8, 2008 at 8:06 AM
I wouldn't expect it to since SelfValidation occurs when you perform validation on an object of that certain type of class which has the HasSelfValidation attribute.  You can also opt to use the ValueConvert event of the PropertyProxyValidator and perform there the validation of your object.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com