['validate', EventPriorities::POST_VALIDATE], ]; } /** * Si l'entité est une instance de ApiResourcesInterface, alors on active le validator * @param ViewEvent $event * @throws \Exception */ public function validate(ViewEvent $event): void { $entity = $event->getControllerResult(); if(!$entity instanceof ApiResourcesInterface) return; $violations = $this->validator->validate($entity); if (0 !== count($violations)) { $messages = []; // there are errors, now you can show them foreach ($violations as $violation) { $messages[] = $violation->getMessage(); } throw new \Exception(join(',', $messages), 500); } } }