/** * Валидирует конкретное значение поля * @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; } }
/** * Валидирует конкретное значение поля * @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; } }