Add error message

@param   string  $message
@param   string  $field
@return  \Globalis\PuppetSkilled\Library\FormValidation
182904
public function add_error($message, $field = null)
    {
        $message = array_values((array)$message);

        // Save the error message
        if (isset($field)) {
            $this->_field_data[$field]['error'] = $message[0];
        }
        $this->_error_array = array_merge($this->_error_array, $message);
        return $this;
    }
99906
public function addValidationError($errorMessage)
    {
        if (is_string($errorMessage)) {
            $this->validationErrors[] = $errorMessage;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given."
            );
        }

        return $this;
    }
917286
public function setError($field, $message) {

    	$instance = $this -> getMessageInstance();

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

		$this -> setPasses(false);

    	return $this;
    }
1151798
protected function addError($property, $message)
    {
        $this->validationErrors->forProperty($property)->addError(new Error($message, time()));
    }
528182
public function validate(Validation $validation, $field) : bool
    {
        if (!is_string($field)) {
            throw new Exception(
                "Field name must be a string"
            );
        }



        $label = $this->getOption("label");

        if (empty($label)) {
            $label = $validation->getLabel($field);
        }



        $value = $validation->getValue($field);

        if ($this->isSetOption("allowEmpty") && empty($value)) {
            return true;
        }



        if (!preg_match('/^[a-zA-Z0-9\-]+$/i', $value)) {
            $message = $this->getOption("message");

            if (empty($message)) {
                $message = "Field :field is not in a valid slug format";
            }



            $replacePairs = [
                ":field" => $label,
            ];

            $validation->appendMessage(
                new Message(
                    strtr($message, $replacePairs),
                    $field,
                    "Slug"
                )
            );

            return false;
        }

        return true;
    }
731491
public void addFieldError(String field, String errorInfo) {

        fieldError.put(field, errorInfo);
        message.put(FrontEndInterfaceConstant.FIELD_STRING, fieldError);
    }
1322676
private function callValidators($value, ValidationField $field) {
        $valid = true;

        // Strip array references in the name except for the last one.
        $key = $field->getSchemaPath();
        if (!empty($this->validators[$key])) {
            foreach ($this->validators[$key] as $validator) {
                $r = call_user_func($validator, $value, $field);

                if ($r === false || Invalid::isInvalid($r)) {
                    $valid = false;
                }
            }
        }

        // Add an error on the field if the validator hasn't done so.
        if (!$valid && $field->isValid()) {
            $field->addError('invalid', ['messageCode' => 'The value is invalid.']);
        }
    }
372916
public function addInteger($field, $errorMsg = null, $emptyIsOk = true)
    {
        $const = ($emptyIsOk) ? self::VALID_INTEGER : self::VALID_INTEGER_REQUIRED;
        $this->addRequired($field, $errorMsg, $const);
    }
1247910
public function setFieldMessage(
        $fieldName,
        $message,
        $messageType = ValidationResult::TYPE_ERROR,
        $messageCast = ValidationResult::CAST_TEXT
    ) {
        $field = $this->fields->dataFieldByName($fieldName);
        if ($field) {
            $field->setMessage($message, $messageType, $messageCast);
        }
        return $this;
    }
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;
    }
764178
public function triggerError($fieldName, $ruleName, $message)
    {
        $this->triggeredErrors[$fieldName][$ruleName] = $message;
        return $this;
    }
461467
public function addError(string $error, array $options = []) {
        $this->validation->addError($this->getName(), $error, $options);
        return $this;
    }
286230
public function addError($field, $validation, $data)
    {
        if (!isset($this->errors[$field])) {
            $this->errors[$field] = array();
        }

        $this->errors[$field][$validation] = $data;
    }
937451
private function validateByRule( $field, $value, $rule, $message = null )
    {
        $ruleClassName = $this->ruleToClassName($this->getRuleName($rule));

        if (!class_exists($ruleClassName)) {
            return false;
        }

        $ruleObject = new $ruleClassName();
        if ($this->isLengthRule($rule)) {
            $ruleObject->setLength($this->extractLength($rule));;
        } else {
            if ($this->isSameRule($rule)) {
                $ruleObject->prepareRule($this->fields, $this->extractSame($rule));
            }
        }
        $result = $ruleObject->run($this->keyToLabel($field), $value, $message);

        if (!$result) {
            static::$errors[ $field ] = $ruleObject->message();
        }

        return $result;
    }
60386
private function errorMessages(string $field, array $errors): array {
        $messages = [];

        foreach ($errors as $error) {
            $messages[] = $this->formatErrorMessage($error + ['field' => $field]);
        }
        return $messages;
    }
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;
    }
1229410
protected function addError($error)
	{
		$this->errors[] = new FileError($error, $this->config['langCallback']);
		$this->isValid = false;
	}