Parent - Collection - Child
So a validity of the children depend on a state of the parent that has the ability to change.
Currently, what I do is I have a stateful property on the collection object (stateful so that any NEW objects in the collection can get the appropriate information) that also cascades the information down to the child objects.
In some similar respects, this behavior is done with the _editLevel - when new items are added to the collection, they get their _editLevelAdded assigned upon insertion.
My concrete case is within a query engine of sorts - I have a parent (not a root, but irrelevant) that represents a piece of data. Based on translations that may occur, the "effective data type" can change. For instance, a string data element - take its length, and you end up with an integer. One can apply any number of crtieria (criterion is my child object). While StringBegins makes sense for a string, it certainly has no meaning for an integer. My "operators" are essentially an enumeration, since there is specific logic that is coded for each one, etc.
When something causes the "effective data type" to change, I tell the collection what the new effective data type is and the collection tells the children. The children have validation rules that look at this effective data type to determine their validity.
Is this kosher?
Copyright (c) Marimer LLC