/**
  * Validate post data
  *
  * @param array $data
  * @return bool     Return FALSE if someone item is invalid
  */
 public function validate($data)
 {
     $errorNo = true;
     if (!empty($data['layout_update_xml']) || !empty($data['custom_layout_update_xml'])) {
         /** @var $validatorCustomLayout \Magento\Framework\View\Model\Layout\Update\Validator */
         $validatorCustomLayout = $this->validatorFactory->create();
         if (!empty($data['layout_update_xml']) && !$validatorCustomLayout->isValid($data['layout_update_xml'])) {
             $errorNo = false;
         }
         if (!empty($data['custom_layout_update_xml']) && !$validatorCustomLayout->isValid($data['custom_layout_update_xml'])) {
             $errorNo = false;
         }
         foreach ($validatorCustomLayout->getMessages() as $message) {
             $this->messageManager->addError($message);
         }
     }
     return $errorNo;
 }
 /**
  * Validate the custom layout update
  *
  * @param \Magento\Framework\DataObject $object
  * @return bool
  * @throws Exception
  */
 public function validate($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $xml = trim($object->getData($attributeName));
     if (!$this->getAttribute()->getIsRequired() && empty($xml)) {
         return true;
     }
     /** @var $validator \Magento\Framework\View\Model\Layout\Update\Validator */
     $validator = $this->_layoutUpdateValidatorFactory->create();
     if (!$validator->isValid($xml)) {
         $messages = $validator->getMessages();
         //Add first message to exception
         $message = array_shift($messages);
         $eavExc = new Exception(__($message));
         $eavExc->setAttributeCode($attributeName);
         throw $eavExc;
     }
     return true;
 }