mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Ensuring array values are strings for sprintf
This commit is contained in:
parent
6169b04cc5
commit
36f4e8d3b1
@ -450,7 +450,18 @@ class Validator
|
|||||||
*/
|
*/
|
||||||
public function error($field, $msg, array $params = array())
|
public function error($field, $msg, array $params = array())
|
||||||
{
|
{
|
||||||
$this->_errors[$field][] = vsprintf($msg, $params);
|
$values = array();
|
||||||
|
// Printed values need to be in string format
|
||||||
|
foreach($params as $param) {
|
||||||
|
if(is_array($param)) {
|
||||||
|
$param = "['" . implode("', '", $param) . "']";
|
||||||
|
}
|
||||||
|
if($param instanceof \DateTime) {
|
||||||
|
$param = $param->format('Y-m-d');
|
||||||
|
}
|
||||||
|
$values[] = $param;
|
||||||
|
}
|
||||||
|
$this->_errors[$field][] = vsprintf($msg, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user