/**
  * @param  integer|integer[] $value
  * @param  Constraint        $constraint
  *
  * @throws InvalidArgumentException
  */
 public function validate($value, Constraint $constraint)
 {
     /* @var $constraint ConfigValue */
     $name = $constraint->name;
     // config must exist
     if (!$this->config->hasFieldConfig($name)) {
         throw new InvalidArgumentException(sprintf('There is no config for the field "%s"', $name));
     }
     // value could be null
     if (null === $value) {
         return;
     }
     // check if field is multivalued
     $multiValued = $this->config->isMultiValued($name);
     // if it's multivalued, an array must be given
     if ($multiValued) {
         if (!is_array($value)) {
             $this->context->addViolation($constraint->arrayMessage);
             return;
         }
         // enforce array
         foreach ($value as $key) {
             $this->validateFieldConfig($constraint, $name, $key);
         }
     } else {
         $this->validateFieldConfig($constraint, $name, $value);
     }
 }
 /**
  * @param string $type
  *
  * @return boolean
  */
 public function supports($type)
 {
     return $this->config->hasFieldConfig($type);
 }