Example #1
0
 private function validateSize(Constraint $constraint, $size, $type, array $parameters)
 {
     if ($constraint->min == $constraint->max && $size != $constraint->max) {
         $this->context->addViolation($constraint->getExactMessage($type), array_merge(array('{{ limit }}' => $constraint->max), $parameters), null, (int) $constraint->max);
         return;
     }
     if (null !== $constraint->max && $size > $constraint->max) {
         $this->context->addViolation($constraint->getMaxMessage($type), array_merge(array('{{ limit }}' => $constraint->max), $parameters), null, (int) $constraint->max);
         return;
     }
     if (null !== $constraint->min && $size < $constraint->min) {
         $this->context->addViolation($constraint->getMinMessage($type), array_merge(array('{{ limit }}' => $constraint->min), $parameters), null, (int) $constraint->min);
     }
 }