Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
Fix ensureAllInRules() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Oct 8, 2014
1 parent c257bf5 commit b16dbb2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/FluxBB/Core/Validator.php
Expand Up @@ -54,26 +54,22 @@ protected function ensureValid(array $attributes)
}

/**
* Make sure all of the given keys exist in our ruleset.
* Make sure all of the keys of the given array exist in our ruleset.
*
* @param array $keys
* @param array $data
* @return $this
* @throws \FluxBB\Server\Exception\ValidationFailed
*/
protected function ensureAllInRules(array $keys)
protected function ensureAllInRules(array $data)
{
$rules = $this->rules();

$invalid = array_filter($keys, function ($key) use ($rules) {
return !isset($rules[$key]);
});
$invalid = array_diff_key($data, $rules);

if (!empty($invalid)) {
throw new ValidationFailed(new MessageBag(
array_map(function ($key) {
return "'$key' is not a valid configuration option.";
}, $invalid)
));
throw new ValidationFailed(new MessageBag([
'Invalid keys found in request.',
]));
}

return $this;
Expand Down

0 comments on commit b16dbb2

Please sign in to comment.