From dae283943fed8639236fb30ef9127eb0bcc74cc9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 27 Nov 2011 13:50:50 -0600 Subject: [PATCH] refactor the validate required method for clarity. --- laravel/validator.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/laravel/validator.php b/laravel/validator.php index 7b6f1e3e..1c72e184 100644 --- a/laravel/validator.php +++ b/laravel/validator.php @@ -211,7 +211,20 @@ protected function error($attribute, $rule, $parameters) */ protected function validate_required($attribute, $value) { - return ! (is_null($value) or (is_string($value) and trim($value) === '')); + if (is_null($value)) + { + return false; + } + elseif (is_string($value) and trim($value) === '') + { + return false; + } + elseif (is_array($value) and count($value) == 0) + { + return false; + } + + return true; } /**