mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
Merge pull request #210 from jatubio/patch-1
Don't prepend field name to error message when {field} is already set in the message
This commit is contained in:
commit
f49917ecfd
@ -1132,11 +1132,21 @@ class Validator
|
|||||||
$msgs = $this->getRuleMessages();
|
$msgs = $this->getRuleMessages();
|
||||||
$message = isset($msgs[$rule]) ? $msgs[$rule] : self::ERROR_DEFAULT;
|
$message = isset($msgs[$rule]) ? $msgs[$rule] : self::ERROR_DEFAULT;
|
||||||
|
|
||||||
|
// Ensure message contains field label
|
||||||
|
if (function_exists('mb_strpos')) {
|
||||||
|
$notContains = mb_strpos($message, '{field}') === false;
|
||||||
|
} else {
|
||||||
|
$notContains = strpos($message, '{field}') === false;
|
||||||
|
}
|
||||||
|
if ($notContains) {
|
||||||
|
$message = '{field} ' . $message;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_validations[] = array(
|
$this->_validations[] = array(
|
||||||
'rule' => $rule,
|
'rule' => $rule,
|
||||||
'fields' => (array) $fields,
|
'fields' => (array) $fields,
|
||||||
'params' => (array) $params,
|
'params' => (array) $params,
|
||||||
'message' => '{field} ' . $message
|
'message' => $message
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user