/**
  * 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;
 }