mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
Merge pull request #91 from ecoreng/filter-refactor
refactor to avoid foreach when filtering
This commit is contained in:
commit
d855c53f94
@ -30,4 +30,5 @@ return array(
|
|||||||
'creditCard' => "debe ser un numero de tarjeta de credito valido",
|
'creditCard' => "debe ser un numero de tarjeta de credito valido",
|
||||||
"lengthMin" => "debe contener mas de %d caracteres",
|
"lengthMin" => "debe contener mas de %d caracteres",
|
||||||
"lengthMax" => "debe contener menos de %d caracteres"
|
"lengthMax" => "debe contener menos de %d caracteres"
|
||||||
|
"instanceOf" => "debe ser una instancia de '%s'"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -78,11 +78,7 @@ class Validator
|
|||||||
{
|
{
|
||||||
// Allows filtering of used input fields against optional second array of field names allowed
|
// Allows filtering of used input fields against optional second array of field names allowed
|
||||||
// This is useful for limiting raw $_POST or $_GET data to only known fields
|
// This is useful for limiting raw $_POST or $_GET data to only known fields
|
||||||
foreach ($data as $field => $value) {
|
$this->_fields = !empty($fields) ? array_intersect_key($data, array_flip($fields)) : $data;
|
||||||
if (empty($fields) || (!empty($fields) && in_array($field, $fields))) {
|
|
||||||
$this->_fields[$field] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set lang in the follow order: constructor param, static::$_lang, default to en
|
// set lang in the follow order: constructor param, static::$_lang, default to en
|
||||||
$lang = $lang ?: static::lang();
|
$lang = $lang ?: static::lang();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user