mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Don't add {field} to message uf already exists
Fixed rule() function to don't add {field} to message if already exists on them
This commit is contained in:
parent
c3d644e1d7
commit
51575f3f9d
@ -1132,11 +1132,16 @@ 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 (mb_strpos($message, '{field}') === false) {
|
||||||
|
$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