Simple.
You create the rule in the Parent object.
That rule then checks the status of the parent. If it is draft then it returns True. In any other case it evaluates all the fields of the contained Address object (or asks it if it IsValid or IsFilledIn) and then returns the appropriate response. If not all filled in you set e.Description with your erro message and you are done.
Joe
What you are saying is that you have a constraint on the Address type, where sometimes all fields are required and sometimes all fields are not required.
This constraint can't (shouldn't) be implemented with knowledge of other objects, therefore it must be encapsulated within Address itself. That probably means a property on Address like AllFieldsRequired, and the validation rules in Address should take AllFieldsRequired into account.
If your Address type is that smart, then your parent types can simply set AllFieldsRequired to true/false depending on whether they want the Address to be required or not.
This keeps Address entirely ignorant of the driving rules - it just knows about its behavior.
And it keeps the parents focused on the constraint, not the behavioral implementation.
Copyright (c) Marimer LLC