/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $length = strlen($this->getValue()); // Check size if (static::MIN_SIZE > $length) { // Too small $result = false; $this->errorMessage = static::t('The length of X field must be greater than Y', array('name' => $this->getLabel(), 'min' => static::MIN_SIZE)); } elseif (static::MAX_SIZE < $length) { // Too big $result = false; $this->errorMessage = static::t('The length of X field must be less than Y', array('name' => $this->getLabel(), 'max' => static::MAX_SIZE)); } else { // Check duplicate $modelId = \XLite\Core\Request::getInstance()->id; $model = $modelId ? \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->find($modelId) : null; $duplicates = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->findDuplicates($this->getValue(), $model); if ($duplicates) { $result = false; $this->errorMessage = static::t('X code is already used for other coupon, please specify a different code', array('code' => $this->getValue())); } } } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result) { $result = $this->checkRange(); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && !preg_match('/^[\\-\\+]{1}([0-9]+)([\\.,]([0-9]+))?([%]{1})?$/Ss', $this->getValue())) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && !preg_match('/^([\\+]\\d{1,3}[ \\.\\-])?([\\(]{1}\\d{2,6}[\\)])?([\\d \\.\\-\\/]{3,20})((x|ext|extension)[ ]?\\d{1,4})?$/Ss', $this->getValue())) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue() && false === filter_var($this->getValue(), FILTER_VALIDATE_EMAIL)) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $parts = @parse_url($this->getValue()); if (!$parts || !isset($parts['scheme']) || !isset($parts['host'])) { $result = false; $this->errorMessage = \XLite\Core\Translation::lbl('The value of the X field has an incorrect format', array('name' => $this->getLabel())); } } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $validator = new \XLite\Core\Validator\SKU($this->getProductId()); try { $validator->validate($this->getValue()); } catch (\XLite\Core\Validator\Exception $exception) { $message = static::t($exception->getMessage(), $exception->getLabelArguments()); $result = false; $this->errorMessage = \XLite\Core\Translation::lbl(($exception->getPublicName() ? static::t($exception->getPublicName()) . ': ' : '') . $message, array('name' => $this->getLabel())); } } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $validator = new \XLite\Core\Validator\String\CleanURL(false, null, '\\XLite\\Module\\CDev\\SimpleCMS\\Model\\Page', \XLite\Core\Request::getInstance()->id); try { $validator->validate($this->getValue()); } catch (\XLite\Core\Validator\Exception $exception) { $message = static::t($exception->getMessage(), $exception->getLabelArguments()); $result = false; $this->errorMessage = \XLite\Core\Translation::lbl(($exception->getPublicName() ? static::t($exception->getPublicName()) . ': ' : '') . $message, array('name' => $this->getLabel())); } } return $result; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $validator = new \XLite\Core\Validator\String\CleanURL(false, null, $this->getParam(self::PARAM_OBJECT_CLASS_NAME), $this->getObjectId()); try { $validator->validate($this->getValue()); } catch (\XLite\Core\Validator\Exception $exception) { $result = false; $this->errorMessage = static::t($exception->getMessage(), $exception->getLabelArguments()); if ($exception->getData()->conflict) { $this->conflict = $exception->getData()->conflict; } } } return $result; }