Dependent validationrules

Dependent validationrules

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


KJosh posted on Saturday, October 10, 2009

I have classes Comapny, Employee, Class B. Company contains employee property, property1(property1 is of type Class B).
Employee has salaries property which is of BusinessListBase. Employee class contains one validation rule on the salaries property. I need to put dependency between property1 and salaries property. When property1 changes executes validation rules dependent on salaries property in Employee class. How to put this type of dependency when adding validation rules?

Thanks

KJosh replied on Sunday, October 11, 2009

Basically the question is, How to put dependency between property of one class and to the class which contains validation rules?

JoeFallon1 replied on Monday, October 12, 2009

A normal dependency exists between two relatively simple properties of a single BO. I do not think your model qualifies.

In this case I would write a new validation rule in the top level Company object which had access to is two child objects Employee and ClassB. Then have the rule run inside Company whenever you call IsValid. (ValidationRulesCheckRules("MySpecialRule")) Or you can try to hook up events and listen for them to run the rule but that is more complex.

Joe

 

KJosh replied on Monday, October 12, 2009

Can you give me example for this? The new validation rule should depend on which property of Company?

JoeFallon1 replied on Tuesday, October 13, 2009

You do not have to use a real Property of Company.

You can create a fake property name instead.

The validation sub-system does not care if it is real or not. It is just that a change to a real property will cause a real rule to run. In this case you are going to run it manually as part of your call to Company.IsValid so using a fake property name is fine.

Joe

 

Copyright (c) Marimer LLC