From e9a43326a7d071f03e6e8f986bb1e9f9dcc8557c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 21 Jul 2011 22:00:23 -0500 Subject: [PATCH] fix bug in validator class required check. --- system/validator.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/system/validator.php b/system/validator.php index 159de8f2..8ab618f0 100644 --- a/system/validator.php +++ b/system/validator.php @@ -137,7 +137,17 @@ protected function check($attribute, $rule) */ protected function validate_required($attribute) { - return array_key_exists($attribute, $this->attributes) and trim($this->attributes[$attribute]) !== ''; + if ( ! array_key_exists($attribute, $this->attributes)) + { + return false; + } + + if (is_string($this->attributes[$attribute]) and trim($this->attributes[$attribute]) === '') + { + return false; + } + + return true; } /**