예제 #1
0
 /**
  * @param $value
  *
  * @return bool
  * @throws InvalidLimitException
  */
 public function verify($value) : bool
 {
     if (!$this->rule->verify($value)) {
         return false;
     }
     if (is_string($value)) {
         return strlen($value) === $this->limit;
     }
     if (is_numeric($value)) {
         return $value === $this->limit;
     }
     throw new InvalidLimitException();
 }
예제 #2
0
 /**
  * @param $value
  *
  * @return bool
  * @throws InvalidRangeException
  */
 public function verify($value) : bool
 {
     if (!$this->rule->verify($value)) {
         return false;
     }
     if (is_string($value)) {
         $len = strlen($value);
         return $len >= $this->min && $len <= $this->max;
     }
     if (is_numeric($value)) {
         return $value >= $this->min && $value <= $this->max;
     }
     throw new InvalidRangeException();
 }