- final int childrenTotal = childrenBefore + childrenAfter + childrenModified;
- Verify.verify(childrenTotal >= 0, "Total child count is %s (from %s and %s)", childrenTotal, modification, current);
-
- if (minElements != null && minElements > childrenTotal) {
- throw new DataValidationFailedException(path, String.format(
- "%s does not have enough elements (%s), needs at least %s", modification.getIdentifier(),
- childrenTotal, minElements));
- }
- if (maxElements != null && maxElements < childrenTotal) {
- throw new DataValidationFailedException(path, String.format(
- "%s has too many elements (%s), can have at most %s", modification.getIdentifier(), childrenTotal,
- maxElements));
- }
+ // Everything passed. We now have a snapshot of the result node, it would be too bad if we just threw it out.
+ // We know what the result of an apply operation is going to be *if* the following are kept unchanged:
+ // - the 'current' node
+ // - the schemacontext (therefore, the fact this object is associated with the modification)
+ //
+ // So let's stash the result. We will pick it up during apply operation.
+ modification.setValidatedNode(this, current, applied);