protected function validate($object)
    {
        $errorList = $this->get('validator')->validate($object);
        if (0 < $errorList->count()) {
            $message = 'Row validation failed.';
            if ($this->getParameter('kernel.debug')) {
                $messages = [];
                /** @var \Symfony\Component\Validator\ConstraintViolationInterface $error */
                foreach ($errorList as $error) {
                    $messages[] = $error->getMessage();
                }
                $message = implode(', ', $messages);
            }
            throw new BadRequestHttpException($message);
        }
    }