Exemplo n.º 1
0
 /**
  * @param array $input
  * @param ConstraintListSet $constraintListSet
  */
 private function validateThatIncomingInputContainsOnlySupportedKeys(array $input, ConstraintListSet $constraintListSet)
 {
     $supportedKeys = $constraintListSet->getKeys();
     $notSupportedKeys = array();
     foreach ($input as $inputKey => $inputValue) {
         if (in_array($inputKey, $supportedKeys) === false) {
             $notSupportedKeys[] = $inputKey;
         }
     }
     if (count($notSupportedKeys) > 0) {
         throw new BadRequestHttpException('The follow keys are not supported: ' . implode(', ', $notSupportedKeys));
     }
 }
Exemplo n.º 2
0
 /**
  * @param ConstraintListSet $constraintListSet
  * @param array $input
  *
  * @throws ValidationExceptionSet
  */
 public function validateListSet(ConstraintListSet $constraintListSet, array $input)
 {
     $validationExceptionSet = new ValidationExceptionSet();
     foreach ($input as $key => $value) {
         $constraintList = $constraintListSet->get($key);
         try {
             $this->validateList($constraintList, $value);
         } catch (ValidationException $validationException) {
             $validationExceptionSet->addException($key, $validationException);
         }
     }
     if ($validationExceptionSet->hasExceptions() === true) {
         throw $validationExceptionSet;
     }
 }