示例#1
0
 /**
  * {@inheritdoc}
  */
 public function guard($value, Field $field)
 {
     /** @var Enum $value */
     Assertion::isInstanceOf($value, 'Gdbots\\Common\\Enum', null, $field->getName());
     Assertion::isInstanceOf($value, $field->getClassName(), null, $field->getName());
     Assertion::integer($value->getValue(), null, $field->getName());
     Assertion::range($value->getValue(), $this->getMin(), $this->getMax(), null, $field->getName());
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function guard($value, Field $field)
 {
     Assertion::integer($value, null, $field->getName());
     $intMin = $this->getMin();
     $intMax = $this->getMax();
     $min = NumberUtils::bound($field->getMin(), $intMin, $intMax);
     $max = NumberUtils::bound($field->getMax(), $intMin, $intMax);
     Assertion::range($value, $min, $max, null, $field->getName());
 }