コード例 #1
0
ファイル: Password.php プロジェクト: shabbirvividads/magento2
 /**
  * @param \Magento\Framework\Object $object
  * @return bool
  */
 public function validate($object)
 {
     $password = $object->getPassword();
     if ($password && $password == $object->getPasswordConfirm()) {
         return true;
     }
     return parent::validate($object);
 }
コード例 #2
0
 /**
  * Implode data for validation
  *
  * @param \Magento\Catalog\Model\Product $object
  * @return bool
  */
 public function validate($object)
 {
     $attributeCode = $this->getAttribute()->getAttributeCode();
     $data = $object->getData($attributeCode);
     if (is_array($data)) {
         $object->setData($attributeCode, implode(',', array_filter($data)));
     }
     return parent::validate($object);
 }
コード例 #3
0
ファイル: Price.php プロジェクト: pavelnovitsky/magento2
 /**
  * Validate
  *
  * @param \Magento\Catalog\Model\Product $object
  * @throws \Magento\Framework\Model\Exception
  * @return bool
  */
 public function validate($object)
 {
     $value = $object->getData($this->getAttribute()->getAttributeCode());
     if (empty($value)) {
         return parent::validate($object);
     }
     if (!preg_match('/^\\d*(\\.|,)?\\d{0,4}$/i', $value) || $value < 0) {
         throw new \Magento\Framework\Model\Exception(__('Please enter a number 0 or greater in this field.'));
     }
     return true;
 }
コード例 #4
0
ファイル: Price.php プロジェクト: nja78/magento2
 /**
  * Validate
  *
  * @param \Magento\Catalog\Model\Product $object
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return bool
  */
 public function validate($object)
 {
     $value = $object->getData($this->getAttribute()->getAttributeCode());
     if (empty($value)) {
         return parent::validate($object);
     }
     if (!$this->isPositiveOrZero($value)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a number 0 or greater in this field.'));
     }
     return true;
 }