Make sure foreach is traversable

This commit is contained in:
Dennis Eichhorn 2017-10-26 20:00:53 +02:00
parent b41fdb7deb
commit 2770bb0d37

View File

@ -39,6 +39,10 @@ final class Validator extends ValidatorAbstract
*/
public static function isValid($var, array $constraints = null) : bool
{
if(!isset($constraints)) {
return true;
}
foreach ($constraints as $callback => $settings) {
$callback = StringUtils::endsWith($callback, 'Not') ? substr($callback, 0, -3) : $callback;
$valid = self::$callback($var, ...$settings);