/** * @param ConstraintViolationListInterface $violations * * @return ValidationException */ public static function create(ConstraintViolationListInterface $violations) { $exception = new ValidationException((string) $violations); $exception->setViolations($violations); return $exception; }
/** * Validates an API request * * @param object $request * * @throws ValidationException */ protected function validate($request) { $violations = $this->getValidator()->validate($request); if (count($violations) > 0) { throw ValidationException::create($violations); } }