Пример #1
0
 /**
  * Валидирует конкретное значение поля
  * @param string $name
  * @return bool
  */
 protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true)
 {
     $value = $attribute->getValue();
     if (!empty($value) && !(bool) preg_match('/^[^@]+@[0-9\\-a-zA-Z_]+\\.[a-zA-Z]{2,6}$/', $value)) {
         if ($setErrors) {
             $attribute->addError($this->message);
         }
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
 /**
  * Валидирует конкретное значение поля
  * @param string $name
  * @return bool
  */
 protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true)
 {
     if (($filter = trim($this->filter)) !== '') {
         $attrValue = $attribute->getValue();
         if (is_array($attrValue)) {
             $value = array_map($filter, $attrValue);
         } else {
             $value = call_user_func($filter, $attrValue);
         }
         $attribute->setValue($value);
     }
     return true;
 }
Пример #3
0
 /**
  * Валидирует конкретное значение поля
  * @param string $name
  * @return bool
  */
 protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true)
 {
     $value = $attribute->getValue();
     /* fix at 05.10.2016, hardcode for bitrix, xml_id */
     $code = $attribute->getCode();
     if ($code == 'xml_id') {
         return true;
     }
     if ($value === null || $value === '') {
         $params = $attribute->getParams();
         if ($setErrors) {
             $attribute->addError(str_replace(['#label#'], [!empty($params['NAME']) ? $params['NAME'] : ''], $this->message));
         }
         return false;
     } else {
         return true;
     }
 }
Пример #4
0
 /**
  * Валидирует конкретное значение поля
  * @param string $name
  * @return bool
  */
 protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true)
 {
     $new = $this->getModel()->isNew();
     if ($new) {
         $attrValue = $attribute->getValue();
         if (is_array($this->defaultArray)) {
             $code = $attribute->getCode();
             if (isset($this->defaultArray[$code])) {
                 $attribute->setValue($this->defaultArray[$code]);
             }
         } else {
             if ($attrValue === null || $attrValue === '') {
                 $attribute->setValue($default);
             }
         }
     }
     return true;
 }