add an error message
@param type $field
@param type $message
@return \oat\oatbox\validator\AbstractFormValidator
424605
protected function addError($field , $message) {
        if(array_key_exists($field, $this->errors)) {
            $this->errors[$field][] = $message;
        } else {
            $this->errors[$field] = [$message];
        }
        return $this;
    }
1338524
public function error($type, $message, $field = null, $options = []) {
		// if its an array of message we process them one by one
		if (is_array($message)) {
			foreach ($message as $v) {
				$this->error($type, $v, $field, $options);
			}
			return;
		}
		// generate hash
		if (!empty($options['unique_options_hash'])) {
			$hash = sha1($message . serialize($options));
		} else {
			$hash = sha1($message);
		}
		// i18n
		if (empty($options['skip_i18n'])) {
			$message = i18n(null, $message, $options);
		}
		// set field error
		if (!empty($field)) {
			if ($type == 'reset') {
				unset($this->errors['fields'][$field]);
				// recalculate
				$this->errors['flag_error_in_fields'] = false;
				$this->errors['flag_warning_in_fields'] = false;
				if (!empty($this->errors['fields'])) {
					foreach ($this->errors['fields'] as $k => $v) {
						foreach ($v as $k2 => $v2) {
							if ($k2 == 'danger') $this->errors['flag_error_in_fields'] = true;
							if ($k2 == 'warning') $this->errors['flag_warning_in_fields'] = true;
						}
					}
				}
			} else {
				array_key_set($this->errors, ['fields', $field, $type, $hash], $message);
				// modals
				if (!empty($this->fields[$field])) {
					$container_link = $this->fields[$field]['options']['container_link'];
					if (($this->data[$container_link]['type'] ?? '') == 'modal') {
						$this->misc_settings['errors_in_modal'][$container_link] = $this->data[$container_link]['options']['modal_id'];
					}
				}
				// set special flag that we have error in fields
				if ($type == 'danger') {
					$this->errors['flag_error_in_fields'] = true;
					$this->errors['flag_num_errors']++;
				}
				if ($type == 'warning') {
					$this->errors['flag_warning_in_fields'] = true;
				}
				// format
				if (!empty($options['format'])) {
					array_key_set($this->errors, ['formats', $field, $type], 1);
				}
			}
		} else {
			if ($type == 'reset') {
				$this->errors['general'] = [];
				$_SESSION['numbers']['forms'][$this->options['parent_form_link'] ?? $this->form_link]['messages'] = [];
				return;
			}
			// subforms need to display messages on parent form
			if (!empty($this->options['on_success_refresh_parent']) && !empty($this->options['parent_form_link']) && $type != 'danger') {
				$_SESSION['numbers']['forms'][$this->options['parent_form_link']]['messages'][$type][$hash] = $message;
				$this->misc_settings['form_postponed_messages'] = true;
				return;
			}
			// regular postponed messages
			if (!empty($options['postponed'])) {
				$_SESSION['numbers']['forms'][$this->options['parent_form_link'] ?? $this->form_link]['messages'][$type][$hash] = $message;
				$this->misc_settings['form_postponed_messages'] = true;
				return;
			}
			// regular messages
			$this->errors['general'][$type][$hash] = $message;
			if ($type == 'danger') {
				$this->errors['flag_num_errors']++;
			}
		}
	}
86660
public function extend($fields, $closure, $message) {

		if(false === is_array($fields)) {
			$fields = [(string) $fields];
		}

		if(false === (gettype($closure) === 'object')) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be a valid callback function, "%s" given', __METHOD__, gettype($closure)), E_USER_ERROR);
		}

		if(false === is_string($message)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($message)), E_USER_ERROR);
		}

		foreach($fields as $field) {
			$this -> addRule(null, $field, null, $closure, $message);
		}
	}
832033
public function withError($message)
    {
        if (is_array($message)) {
            $this->errorBag->setErrors($message);
        } else {
            $this->errorBag->add($message);
        }

        return $this;
    }
308350
public function add_rule($field, $rule) {

		if(!$rule instanceof \HybridLogic\Validation\Rule) return $this;

		if(!isset($this->labels[$field])) {
			$this->set_label($field, $this->humanize_field_name($field));
		}

		if(!isset($this->rules[$field])) $this->rules[$field] = array();
		$this->rules[$field][] = $rule;

		return $this;

	}
517475
public function setMessage($type, $message)
    {
        if (!is_null($message)) {
            $this->messages[] = [
                'message' => $message,
                'type'    => $type,
            ];
        }

        return $this;
    }
406966
public function add($message, $type = 'error')
    {
        $this->session[$this->prefix][] = ['message' => $message, 'type' => $type];

        return $this;
    }
223429
public function setError($field, $error = 'Error de validación')
    {
        $this->fields[$field]['error'] = $error;
        $this->errors[$field] = $error;
        return $this;
    }
1151798
protected function addError($property, $message)
    {
        $this->validationErrors->forProperty($property)->addError(new Error($message, time()));
    }
917286
public function setError($field, $message) {

    	$instance = $this -> getMessageInstance();

    	$instance :: setFieldnames([$field]);
		$instance :: setError($this -> getPrefix(), $field, $message);

		$this -> setPasses(false);

    	return $this;
    }
12197
public function addError($fieldName, $ruleName, $message)
    {
        $this->errors[$fieldName][$ruleName] = $message;

        return $this;
    }
1373902
public static function addErrorMessage($message, $num = E_USER_ERROR, $file = '', $line = 0, $context = array())
	{
		if (is_array($message)) {
			$message = implode(' ', $message);
		}
		$exception = new \ErrorException($message, 0, $num, $file, $line);
		$exception->context = $context;

		return self::addError($exception, true);
	}
447013
public function error(string $field, string $message, array $params = [])
    {
        $message = $this->checkAndSetLabel($field, $message, $params);

        $values = [];
        // Printed values need to be in string format
        foreach ($params as $param) {
            if (\is_array($param)) {
                $param = "['" . implode("', '", $param) . "']";
            } elseif ($param instanceof \DateTime) {
                $param = $param->format('Y-m-d');
            } elseif (\is_object($param)) {
                $param = \get_class($param);
            }

            // Use custom label instead of field name if set
            if (\is_string($params[0]) && isset($this->_labels[$param])) {
                $param = $this->_labels[$param];
            }
            $values[] = $param;
        }

        $this->_errors[$field][] = \vsprintf($message, $values);
    }
189727
public static function createFromField(Field $field): self
    {
        $message = new self();
        $message->setId($field->getId());
        $message->setToken($field->getToken());
        $message->setDescription($field->getDescription());

        foreach ($field->getTranslations() as $translation) {
            $transMessage = FieldTranslationMessage::createFromFieldTranslation($translation);

            $message->addTranslation($transMessage);
        }

        return $message;
    }
399538
public function withErrors($errors, $message = null)
    {
        if (! $errors instanceof MessageBag) {
            $errors = new MessageBag((array) $errors);
        }

        if (! is_null($message)) {
            $errors->add('__message', $message);
        }

        $this->with('errors', $errors->toArray());

        return $this;
    }
735012
protected function storeTranslationsForFieldValidation(Field $field)
    {
        if (false === $this->translationsForFieldValidationWereInjected($field)) {
            $fieldName = $field->getName();

            foreach ($field->getValidation() as $validationName => $validation) {
                $messages = ValidatorService::get()->getValidatorMessages($validation->getClassName(), $validation->getMessages());

                foreach ($messages as $key => $message) {
                    $message = MessageService::get()->parseMessageArray($message, ['{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}']);

                    $localizationKey = $this->getIdentifierForFieldValidationName($field, $validationName, $key);
                    $this->addTranslation($localizationKey, $message);
                    $messages[$key] = $localizationKey;
                }

                $this->translationKeysForFieldValidation[$fieldName . '-' . $validationName] = $messages;

                $key = $this->getFormObject()->getClassName() . '-' . $field->getName();
                $this->injectedTranslationKeysForFieldValidation[$key] = true;
            }
        }

        return $this;
    }
311982
public function addIsObjectValidation($field, $cancelOnFail = true)
    {
        if (!is_null($this->getValue($field))) {
            $this->add($field, new InlineValidator([
                'function' => function () use ($field) {
                    return is_object($this->getValue($field));
                },
                'message' => sprintf(ValidationMessages::PARAMETER_MUST_BE_AN_OBJECT, $field),
                'cancelOnFail' => $cancelOnFail
            ]));
        }
    }