Build the error message of a rule.
@param  string $ruleName
@param  Rule $rule
@param  string $default  default message
@param  mixed $input
@return string
761165
protected function buildRuleMessage($ruleName, $rule=null, $default=null, $input=null) {
		if($message = $this->getRuleMessage($ruleName)) {}
		elseif($message = $this->getRegistry()->getMessage($ruleName)) {}
		elseif($rule !== null && $message = $rule->getMessage()) {}
		elseif($default !== null && $message=$default) {}
		elseif($message = $this->getDefaultMessage()) {}
		else $message = ':attribute is not valid.';

		$params = [
			'attribute' => $this->getName(),
		];
		if(is_string($input) || is_numeric($input))
			$params['input'] = $input;
		if($rule instanceof Rule) {
			$params = array_merge($params, get_object_vars($rule));
			$rule->formatParameters($params);
		}

		if($this->getTranslator())
			$message = $this->getTranslator()->trans($message);

		return $this->format($message, $params);
	}
342009
private static function addMessage($rule, $params) {

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

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

		if(false === isset($params[0])) {
			return trigger_error(sprintf('Params passed to %s() are not well formed', __METHOD__), E_USER_ERROR);
		}

		foreach(static :: $fieldnames as $fieldname) {

			if(false === isset(static :: $messages[$fieldname][$rule])) {
				static :: $messages[$fieldname][$rule] = [];
			}

			static :: $messages[$fieldname][$rule] = $params[0];
		}
	}
225257
private function error($field, &$bind)
    {
        $label = (isset($this->label[$field]) && !empty($this->label[$field])) ? $this->label[$field] : $field;
        $this->errorMsg[$field][] = vsprintf(str_replace('{field}', $label, (isset($bind['message']) ? $bind['message'] : '{field} ' . self::$errorTip[strtolower($bind['rule'])])), $bind['params']);
    }
942761
protected function addError($attribute, $rule, $parameters)
    {
        $message = $this->getMessage($attribute, $rule);

        $message = $this->doReplacements($message, $attribute, $rule, $parameters);

        $this->messages->add($attribute, $message);
    }
462958
private function validateInput($input, $rules, $key)
    {
        if (isset($input[$key]) && isset($rules[$key])) {
            $ruleExp = explode('|', $rules[$key]);

            foreach ($ruleExp as $rule) {
                $this->parseRule($rule, $input, $key);
            }
        }
    }
911944
public function message(string $message, string $attribute, string $rule): string
    {
        if ("validation.{$rule}" !== $message) {
            return $message;
        }

        return $this->getTranslatedMessageFallback(
            str_replace('mongolid_', '', $rule),
            $attribute
        );
    }
995786
public function addRule($rule, $method = null, $params = [], $message = null)
    {

        // construction des paramètres
        array_unshift($params, $rule, $method);

        call_user_func_array([$this->getValidator(), 'addRule'], $params);

        if (!is_null($message)) {
            if(is_array($message)){
                foreach($message as $rule => $message){
                    $this->getValidator()->addMessage($rule, $message);
                }
            }else{
                $this->getValidator()->addMessage($rule, $message);
            }
        }

        return $this;
    }
160850
public function getRuleProviderDefault() : RuleProviderInterface
    {
        $container = Dependency::container();
        return $container->has('validate') ? $container->get('validate') : Validate::getInstance();
    }
838274
public function error($rule=null) {
		if($rule === null)
			return $this->self;
		elseif(isset($this->rules[$rule]))
			return $this->rules[$rule];
		elseif($attribute = $this->attribute($rule))
			return $attribute->error();
	}
833782
public function rule($field, $rules = [])
    {
        $defaults = [
            'message' => null,
            'required' => true,
            'skipEmpty' => false,
            'format' => 'any',
            'not' => false,
            'on' => null
        ];

        $rules = $rules ? (array) $rules : [];

        foreach ($rules as $name => $options) {
            if (is_numeric($name)) {
                $name = $options;
                $options = [];
            }
            if (is_string($options)) {
                $options = ['message' => $options];
            }
            $options += $defaults;
            $this->_rules[$field][$name] = $options;
        }
    }
525348
protected function getRealRuleByName($field, $ruleName)
    {
        if (empty($ruleName) || !is_string($ruleName)) {
            $ruleName = Util::pathOfUrl(URL::previous());
        }
        if ($staticRule = $this->getStaticRule($field, $ruleName)) {
            $this->useRule($field, $ruleName);

            return $staticRule;
        }
        if ($dynamicRule = $this->retrieveRule($field, $ruleName)) {
            $this->useRule($field, $ruleName);

            return $dynamicRule;
        }
        $default = self::getNameOfDefaultStaticRule($field);
        if ($staticRule = $this->getStaticRule($field, $default)) {
            $this->useRule($field, $default);

            return $staticRule;
        }

        return '';
    }
1155825
protected function getMessage($attribute, $rule, $replace = [])
    {

        $custemKey = "validation.custom.{$attribute}.{$rule}";

        $custemMessage = trans($custemKey, $replace);
        if ($custemMessage != $custemKey) {
            return $custemMessage;
        } elseif (in_array($rule, $this->sizeRules)) {
            $type = $this->getAttributeType($attribute);
            $key = "validation.{$rule}.{$type}";
            return trans($key, $replace);
        }

        return trans("validation.{$rule}", $replace);
    }
690061
public function input($name, $default = null)
    {
        $value = e($this->value($name, $default));
        $name = e($name);
        return "name=\"$name\" value=\"$value\"";
    }
1181986
public function getRule($ruleName)
    {
        if(!$this->hasRule($ruleName)) {
            throw new RuleNotFoundException(RuleNotFoundException::formatMessage($ruleName));
        }

        return $this->rules[$ruleName];
    }
184554
protected function addMessage($key, $rule, $specialRule, array $datas = [])
    {
        $specialMessages = $this->getMessageReposity();
        $defaultMessages = $this->defaultErrorMessages;

        if (count($datas) === 0) {
            $datas = [$key];
        }

        if (isset($specialMessages[$specialRule])) {
            $selectedMessage = $specialMessages[$specialRule];
        } else {
            $selectedMessage = $defaultMessages[$rule];
        }

        array_unshift($datas, $selectedMessage);
        $this->failedMessages[] = call_user_func_array('sprintf', $datas);
    }
1081202
public function forceErrorNext ($url, $rule = self::NEXT_FORWARD) {
		$this->rule->next['error'][0] = $url;
		$this->rule->next['error'][1] = $rule;
	}
1258530
protected function getErrorMessage(RuleInterface $rule, string $field, object $parsedRule): string
	{
		$field = $this->getOriginalFieldName($field);

		if($this->i18n !== null && $rule instanceof I18nAwareInterface)
		{
			return $rule->setI18n($this->i18n)->getTranslatedErrorMessage($field, $parsedRule->name, $parsedRule->package);
		}

		return $rule->getErrorMessage($field);
	}