/**
  * @param ElementInterface $element
  *
  * @throws ValidationError
  */
 public function validate(ElementInterface $element)
 {
     if ($element->isLeaf()) {
         if (strlen($element->getContent()) === 0) {
             throw new ValidationError(sprintf($this->message, 'content'));
         }
     } else {
         if (count($element->getChildren()) === 0) {
             throw new ValidationError(sprintf($this->message, 'children[]'));
         }
     }
 }
 /**
  * @param ElementInterface $element
  *
  * @throws ValidationError
  */
 public function validate(ElementInterface $element)
 {
     $children = $element->getChildren();
     $allowed = $element->getAllowedChildren();
     $unallowed = [];
     foreach ($children as $child) {
         if (!in_array($child->getName(), $allowed)) {
             $unallowed[] = $child->getName();
         }
     }
     if (count($unallowed) > 0) {
         throw new ValidationError(sprintf($this->message, $element->getName(), implode(', ', $unallowed), implode(', ', $element->getAllowedChildren())));
     }
 }