- @Override
- protected TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) {
- return delegate.applyTouch(modification, currentMeta, version);
+ private void validateMinMaxElements(final ModificationPath path, final NormalizedNode<?, ?> value)
+ throws DataValidationFailedException {
+ final PathArgument id = value.getIdentifier();
+ final int children = numOfChildrenFromValue(value);
+ if (minElements > children) {
+ throw new RequiredElementCountException(path.toInstanceIdentifier(), minElements, maxElements, children,
+ "%s does not have enough elements (%s), needs at least %s", id, children, minElements);
+ }
+ if (maxElements < children) {
+ throw new RequiredElementCountException(path.toInstanceIdentifier(), minElements, maxElements, children,
+ "%s has too many elements (%s), can have at most %s", id, children, maxElements);
+ }