/** * Checks if the field value is not empty. * * @param AbstractField $field The field. */ protected function isValid($field) { $value = $field->getValue(); if ($value === null || $value === '' || is_array($value) && empty($value)) { $this->addError($this->translateErrorMessage('fields.validation.empty_value', Core::getExtensionKey()), 1431103424); } }
/** * Checks if a given field is correctly filled. * * @param Fields\AbstractField $field The field. * @return array An array with 2 indexes: * - fieldLabel: The translated label of the field. * - validationResult: List of TYPO3\CMS\Extbase\Error\Result */ public function validateField(Fields\AbstractField $field) { $fieldValidation = array('fieldLabel' => Core::translate($field->getLabel())); $validationResult = $field->validate()->getValidationResult(); $fieldValidation['validationResult'] = $validationResult; return $fieldValidation; }
/** * Checks if the field value matches a domain name value. * * @param AbstractField $field The field. */ protected function isValid($field) { if (!preg_match('/^[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,6}$/', $field->getValue())) { $this->addError($this->translateErrorMessage('fields.validation.domain_name_value', Core::getExtensionKey()), 1431104484); } }
/** * Checks if the field value matches a hexadecimal value. * * @param AbstractField $field The field. */ protected function isValid($field) { if (!preg_match('/^#[0123456789ABCDEF]{6}$/', strtoupper($field->getValue()))) { $this->addError($this->translateErrorMessage('fields.validation.wrong_hexadecimal_value', Core::getExtensionKey(), ['s' => $field->getValue()]), 1430127326); } }
/** * Checks if the field value matches a Facebook URL. * * @param AbstractField $field The field. */ protected function isValid($field) { if (!preg_match('/^$|^(https:\\/\\/)?(www.)?facebook.com\\/.+$/', $field->getValue())) { $this->addError($this->translateErrorMessage('fields.validation.facebook_url_value', Core::getExtensionKey()), 1431104928); } }
/** * Checks if the field value matches a domain name value. * * @param \Romm\SiteFactory\Form\Fields\AbstractField $field The field. */ protected function isValid($field) { if (filter_var($field->getValue(), FILTER_VALIDATE_INT) === FALSE) { $this->addError($this->translateErrorMessage('fields.validation.integer_value', Core::getExtensionKey()), 1431105694); } }