I have a collection of parent objects that need to have a property to filter business rule validation for themselves and all children. There is a complex hierarchy of child, grandchild and so on objects. These children need to skip validation when the property is set on the parent most object.
I need some suggestions on how to get the children to alter their validation in this manner.
We're using CSLA 3.8
I think I'd look at doing a cascading call from the parent to its child objects when the property is set. This can be done using a business rule method attached to the parent property.
Implement internal methods (or an interface) that allows the parent to easily loop through all the child objects, calling a method so the child object can update its own status to mirror that of its parent.
The thing to remember is that objects shouldn't control or manipulate other objects. So if a parent would like to ask its child objects to not validate, that's OK - and this would do exactly that.
What you'll probably find helpful is that ValidationRules has a property an object can set to disable validation processing globally for that object. This feature exists to support batch loading of properties in a web or service app setting, but should work well for you in this case.
The business and validation rules video in the Core CSLA 3.8 video series covers suppressing validation in this manner.
Copyright (c) Marimer LLC