For example: let us say that one of the Z14/Implementations in the list held in Z8K4 of a Z8/Function is a Z9/Reference. Even if that Reference points to something that's not actually a Z14, no error will be propagated.
The mutate function should validate the result against the expected type, which can be determined by looking at the key of the object being mutated.
I see two possible ways to implement this:
- Create a copy of the input ZObject; set the key corresponding to the original reference to the resolved/mutated element; re-run validation on the top-level object. This is incredibly wasteful, since it means re-running validation on the entire object multiple times, even for the keys that haven't changed.
- Create intermediate-level references in all of the JSON schemata corresponding to builtin types. For example, instead of saying that Z7K1 of a Z7 is a Z8, define in the JSON schema a nonterminal node Z7K1 which Z7.Z7K1 must validate as. Then a schema for Z7K1 can be created independently so that, if mutate(Z7K1) is called on a Z8, the result can be validated as Z7K1. In this way, we won't re-run the same validation on any objects, but we'll have to rewrite all of the builtin schemata. Note that this will be much easier when validating generic or builtin types (basically anything where we create the validator directly from a Z4), since the GenericSchema class already maintains a mapping from an object's keys to the corresponding sub-validators.