Commit 431d8864 by Qiang Xue

refactored RangeValidator.

parent 10889474
...@@ -63,18 +63,16 @@ class RangeValidator extends Validator ...@@ -63,18 +63,16 @@ class RangeValidator extends Validator
return [$this->message, []]; return [$this->message, []];
} }
$valid = false; $in = true;
foreach ((array)$value as $v) { foreach ((array)$value as $v) {
$valid = !$this->not && in_array($v, $this->range, $this->strict) if (!in_array($v, $this->range, $this->strict)) {
|| $this->not && !in_array($v, $this->range, $this->strict); $in = false;
if (!$valid) {
break; break;
} }
} }
return $valid ? null : [$this->message, []]; return ($this->not xor $in) ? null : [$this->message, []];
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment