Return error message for this Rule

@param string Field name
@param string Field value
@param Validator Validator object
@return string Error message
166856
public function get_error_message($field, $value, $validator) {
		return $validator->get_label($field) . ' must match ' . $validator->get_label($this->compare_against);
	}
1080660
function (name, validation) {
		if (name == null && validation == null) {
			delete this.isRequired;
			return this;
		}

		return this.field(name).validate(validation);
	}
1169667
public function rule($rule, $fields, ...$params)
    {
        if (\is_callable($rule)
            && !(\is_string($rule) && $this->hasValidator($rule))
        ) {
            $name = $this->getUniqueRuleName($fields);
            $message = $params[0] ?? null;
            $this->addInstanceRule($name, $rule, $message);
            $rule = $name;
        }

        $errors = $this->getRules();
        if (!isset($errors[$rule])) {
            $ruleMethod = 'validate' . \ucfirst($rule);
            if (!\method_exists($this, $ruleMethod)) {
                throw new \InvalidArgumentException("Rule '" . $rule . "' has not been registered with " . __CLASS__ . "::addRule().");
            }
        }

        // Ensure rule has an accompanying message
        $messages = $this->getRuleMessages();
        $message = $messages[$rule] ?? self::ERROR_DEFAULT;

        // Ensure message contains field label
        if (\strpos($message, '{field}') === false) {
            $message = '{field} ' . $message;
        }

        $this->_validations[] = [
            'rule' => $rule,
            'fields' => (array) $fields,
            'params' => (array) $params,
            'message' => '{field} ' . $message,
            'skip' => self::SKIP_CONTINUE,
        ];

        return $this;
    }
1208007
public function error($fieldName, $str)
    {
        // by using this hook you can overwrite default behavior of this method
        if ($this->hookHasCallbacks('displayError')) {
            return $this->hook('displayError', [$fieldName, $str]);
        }

        $jsError = [$this->js()->form('add prompt', $fieldName, $str)];

        return $jsError;
    }
1251762
protected function validateField(string $field, string $rule): bool
	{
		$parsedRule = $this->parseRule($rule);

		$rule = $this->ruleFactory($parsedRule->name, $parsedRule->parameters);

		// Just return true if the input field is empty and the rule doesn't validate empty input

		if($this->isInputFieldEmpty($inputValue = Arr::get($this->input, $field)) && $rule->validateWhenEmpty() === false)
		{
			return true;
		}

		// Validate input

		if($rule->validate($inputValue, $this->input) === false)
		{
			$this->errors[$field] = $this->getErrorMessage($rule, $field, $parsedRule);

			return $this->isValid = false;
		}

		return true;
	}
540405
public function error_message($field = null, $default = false)
	{
		if ($field === null)
		{
			$messages = array();
			foreach ($this->error() as $field => $e)
			{
				$messages[$field] = $e->get_message();
			}
			return $messages;
		}

		return array_key_exists($field, $this->errors) ? $this->errors[$field]->get_message() : $default;
	}
426271
public static function getMessage($field, $rule) {

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

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

		if(true === isset(static :: $messages[$field][$rule])) {
			return static :: $messages[$field][$rule];
		}
	}
1221017
function (name, value, options) {
    if (options) {
        return validator[name](value, options) ? null : (_a = {},
            _a[name] = {
                valid: false
            },
            _a);
    }
    return validator[name](value) ? null : (_b = {},
        _b[name] = {
            valid: false
        },
        _b);
    var _a, _b;
}
224245
function getError(field, value) {
	// Check we actually got a string
	if (typeof value !== "string") {
		return errorInvalidParams(field + " must be a string");
	}
	// Check value is not empty
	if (!value.trim()) {
		return errorInvalidParams(field + " must not be empty");
	}
}
1156905
private function getValidation(string $name): validator\Validation
    {
        if (!isset($this->validations[$name])) {
            if (isset($this->validationRegister[$name])) {
                $class = $this->validationRegister[$name];
            } else {
                throw new exceptions\ValidatorException("Validator [$name] not found");
            }

            $params = isset($this->validationData[$name]) ? $this->validationData[$name] : null;
            $this->validations[$name] = new $class($params);
        }
        return $this->validations[$name];
    }
518165
public static function validateFiled(array $data, string $field_value, array $field_rules, array $messages = [])
    {
        $errors = [];

        foreach ($field_rules as $check => $check_value) {

            switch ($check) {

                case 'required':
                    if (!$field_value) {
                        $errors[$check] = isset($messages['required']) ? w($messages['required']) : self::$messages['required'];
                    }

                    break;

                case 'min_length':

                    if (mb_strlen($field_value) < $check_value) {
                        $errors[$check] = sprintf(isset($messages['min_length']) ? w($messages['min_length']) : self::$messages['min_length'], $check_value);
                    }

                    break;

                case 'max_length':

                    if (mb_strlen($field_value) > $check_value) {
                        $errors[$check] = sprintf(isset($messages['max_length']) ? w($messages['max_length']) : self::$messages['max_length'], $check_value);
                    }

                    break;

                case 'min':

                    if ($field_value < $check_value) {
                        $errors[$check] = sprintf(isset($messages['min']) ? w($messages['min']) : self::$messages['min'], $check_value);
                    }

                    break;

                case 'max':

                    if ($field_value > $check_value) {
                        $errors[$check] = sprintf(isset($messages['max']) ? w($messages['max']) : self::$messages['max'], $check_value);
                    }

                    break;

                case 'pattern':

                    if (!preg_match($check_value, $field_value)) {
                        $errors[$check] = $check_value;
                    }

                    break;

                case 'min_checkboxes_checked':

                    break;

                case 'max_checkboxes_checked':

                    break;

                case 'equal_to_field':

                    if (!isset($data[$check_value]) || $field_value != $data[$check_value]) {
                        $errors[$check] = sprintf(isset($messages['max']) ? w($messages['max']) : self::$messages['max'], $check_value);
                    }

                    break;

                // Is used for invisible fields, substituting captcha: if filled, it is invalid
                case 'empty':

                    if (!empty($field_value)) {
                        $errors[$check] = isset($messages['empty']) ? w($messages['empty']) : self::$messages['empty'];
                    }

                    break;

                case 'type':

                    switch ($check_value) {

                        case 'email':

                            if (!Verify::email($field_value)) {
                                $errors[$check] = isset($messages['type']) ? w($messages['type']) : self::$messages['email'];
                            }

                            break;

                        case 'number':

                            if (!is_numeric($field_value)) {
                                $errors[$check] = isset($messages['type']) ? w($messages['type']) : self::$messages['number'];
                            }

                            break;

                        case 'integer':

                            if (!\is_numeric($field_value) || !filter_var($field_value, FILTER_VALIDATE_INT)) {
                                $errors[$check] = isset($messages['type']) ? w($messages['type']) : self::$messages['integer'];
                            }

                            break;

                        case 'digits':

                            if (!ctype_digit($field_value)) {
                                $errors[$check] = isset($messages['type']) ? w($messages['type']) : self::$messages['digits'];
                            }

                            break;

                        case 'alphanum':

                            if (!ctype_alnum($field_value)) {
                                $errors[$check] = isset($messages['type']) ? w($messages['type']) : self::$messages['aphanum'];
                            }

                            break;

                        case 'url':

                            if (!filter_var($field_value, FILTER_VALIDATE_URL)) {
                                $errors[$check] = isset($messages['url']) ? w($messages['url']) : self::$messages['url'];
                            }

                            break;
                    }

                    break;
            }
        }

        return empty($errors) ? true : $errors;
    }
832267
public function getFieldValue(string $field_name)
    {
        if (false === $this->validated) {
            $this->validate();
        }
        foreach ($this->validators as $validator) {
            if ($validator->getFieldName() == $field_name) {
                return $validator->getValue();
            }
        }
        throw new InvalidInputException('A field called ' . $field_name . ' was not defined.');
    }
134294
function invalidChar(name, field = undefined) {
  let msg = `Invalid character in ${name}`;
  if (field !== undefined) {
    msg += ` ["${field}"]`;
  }
  return msg;
}
876766
public function isValidField(string $field): bool {
        $result = empty($this->errors[$field]);
        return $result;
    }
640146
def validate_config(config_json, fields):
    """"""
    for field_name, validator_obj in six.iteritems(fields):
        field_value = config_json.get(field_name, None)
        if field_value is None:
            raise exceptions.ConfigFieldMissing(field_name)

        if not validator_obj.validator_func(field_value):
            raise exceptions.ConfigFieldValidationError(field_name, field_value, validator_obj.get_error_message())
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);
    }
1153024
public function validate($field, $value, $validator) {
		$value2 = $validator->get_data($this->compare_against);
		return $value === $value2;
	}