From 368dd4b1d4f1e4ebac4abe8b8954b44ed460db00 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 13 Nov 2013 19:50:19 -0500 Subject: [PATCH] Allow Validator::except to be either a string or an array. --- framework/yii/validators/Validator.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/framework/yii/validators/Validator.php b/framework/yii/validators/Validator.php index 36a1af4..2cd611b 100644 --- a/framework/yii/validators/Validator.php +++ b/framework/yii/validators/Validator.php @@ -94,7 +94,8 @@ abstract class Validator extends Component */ public $on = []; /** - * @var array list of scenarios that the validator should not be applied to. + * @var array|string scenarios that the validator should not be applied to. For multiple scenarios, + * please specify them as an array; for single scenario, you may use either a string or an array. */ public $except = []; /** @@ -163,12 +164,9 @@ abstract class Validator extends Component public function init() { parent::init(); - if (!is_array($this->attributes)) { - $this->attributes = (array)$this->attributes; - } - if (!is_array($this->on)) { - $this->on = (array)$this->on; - } + $this->attributes = (array)$this->attributes; + $this->on = (array)$this->on; + $this->except = (array)$this->except; } /**