Example #1
0
 /**
  * Validate data
  *
  * @param \Magento\Sales\Model\Order\Shipment\Comment $comment
  * @return array
  */
 public function validate(Comment $comment)
 {
     $errors = [];
     $commentData = $comment->getData();
     foreach ($this->required as $code => $label) {
         if (!$comment->hasData($code)) {
             $errors[$code] = sprintf('%s is a required field', $label);
         } elseif (empty($commentData[$code])) {
             $errors[$code] = sprintf('%s can not be empty', $label);
         }
     }
     return $errors;
 }