Commit 431d8864 by Qiang Xue

refactored RangeValidator.

parent 10889474
......@@ -63,18 +63,16 @@ class RangeValidator extends Validator
return [$this->message, []];
}
$valid = false;
$in = true;
foreach ((array)$value as $v) {
$valid = !$this->not && in_array($v, $this->range, $this->strict)
|| $this->not && !in_array($v, $this->range, $this->strict);
if (!$valid) {
if (!in_array($v, $this->range, $this->strict)) {
$in = false;
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