diff --git a/framework/assets/yii.validation.js b/framework/assets/yii.validation.js index b0564c3..20ca83c 100644 --- a/framework/assets/yii.validation.js +++ b/framework/assets/yii.validation.js @@ -91,10 +91,24 @@ yii.validation = (function ($) { if (options.skipOnEmpty && pub.isEmpty(value)) { return; } - var valid = !options.not && $.inArray(value, options.range) > -1 - || options.not && $.inArray(value, options.range) == -1; - if (!valid) { + if (!options.allowArray && $.isArray(value)) { + pub.addMessage(messages, options.message, value); + return; + } + + var inArray = true; + + $.each($.isArray(value) ? value : [value], function(i, v) { + if ($.inArray(v, options.range) == -1) { + inArray = false; + return false; + } else { + return true; + } + }); + + if (options.not !== inArray) { pub.addMessage(messages, options.message, value); } }, diff --git a/framework/validators/RangeValidator.php b/framework/validators/RangeValidator.php index 08ea03a..1c8482e 100644 --- a/framework/validators/RangeValidator.php +++ b/framework/validators/RangeValidator.php @@ -72,7 +72,7 @@ class RangeValidator extends Validator } } - return ($this->not xor $in) ? null : [$this->message, []]; + return $this->not !== $in ? null : [$this->message, []]; } /** @@ -94,6 +94,9 @@ class RangeValidator extends Validator if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; } + if ($this->allowArray) { + $options['allowArray'] = 1; + } ValidationAsset::register($view);