From e8ab4dc15724bb341efd2ac2b3da69f3fc113081 Mon Sep 17 00:00:00 2001 From: Elizabeth M Smith Date: Fri, 23 Jun 2017 14:01:34 -0400 Subject: [PATCH] Fixes invalid argument to foreach happens when you have a rule looking for sub items in arrays, but actually pass in a scalar value bombs out with invalid argument to foreach --- src/Valitron/Validator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 5fc5c84..db79f39 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -889,6 +889,11 @@ class Validator if (is_array($identifiers) && count($identifiers) === 0) { return array($data, false); } + + // Catches the case where the data isn't an array or object + if (is_scalar($data)) { + return array($data, false); + } $identifier = array_shift($identifiers);