Validation rule not bound to a property

Validation rule not bound to a property

Old forum URL: forums.lhotka.net/forums/t/5993.aspx


Valentin_Vasiliev posted on Monday, December 15, 2008

Hello, friends.
Is there a way to create a validation rule without property binding?
I want a validation rule per se, that would be evaluated only on "CheckRules" method call.

Thanks.
Valentin.

ajj3085 replied on Monday, December 15, 2008

No, it must be associated with a property.  You can make a dummy property... or maybe even get away with using a property name which doesn't exist.  Either way, you'll have to call CheckRules or CheckRules( string propertyName ) to run the rule.

JoeFallon1 replied on Monday, December 15, 2008

You can definitely "get away with" usnig a PropertyName which does not really exist.

I do it all the time.

For these kinds of properties I usually override IsValid and call CheckRules("fakeName") and then MyBase.IsValid.

In other words, I only check them after all propeties are set and I am checking the validity of the BO as a whole.

Joe

 

Copyright (c) Marimer LLC