From cbf2399ab86e0c122ada5b8b93d812e681ca3f38 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 30 Jun 2011 13:36:39 -0700 Subject: [PATCH 1/2] Default Validator target to Input data. --- system/validator.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/validator.php b/system/validator.php index 895a22d4..eb4532f0 100644 --- a/system/validator.php +++ b/system/validator.php @@ -29,10 +29,15 @@ class Validator { * @param mixed $target * @return void */ - public function __construct($target = array()) + public function __construct($target = null) { $this->errors = new Validation\Error_Collector; + if (is_null($target)) + { + $target = Input::get(); + } + // --------------------------------------------------------- // If the source is an Eloquent model, use the model's // attributes as the validation attributes. @@ -46,7 +51,7 @@ class Validator { * @param mixed $target * @return Validator */ - public static function make($target = array()) + public static function make($target = null) { return new static($target); } From 0013e5bcbe44cf04cbc005c3e5bdbd2a082dd309 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 30 Jun 2011 13:46:11 -0700 Subject: [PATCH 2/2] Fixed bug in validator message handling for empty file uploads. --- system/validation/message.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/validation/message.php b/system/validation/message.php index 50d93746..34fc95a1 100644 --- a/system/validation/message.php +++ b/system/validation/message.php @@ -88,6 +88,17 @@ class Message { */ private static function get_upload_of_message($rule) { + // --------------------------------------------------------- + // Upload_Of rules sometimes set a "presence_of" error. + // + // This occurs when the uploaded file didn't exist and the + // "not_required" method was not called. + // --------------------------------------------------------- + if ($rule->error == 'presence_of') + { + return static::get_message($rule); + } + // --------------------------------------------------------- // Slice "file_" off of the error type. // ---------------------------------------------------------