src/Bridge/Symfony/Validator/EventListener/ValidationExceptionListener.php
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();
        if (!$exception instanceof ValidationException) {
            return;
        }

        $format = ErrorFormatGuesser::guessErrorFormat($event->getRequest(), $this->errorFormats);

        $event->setResponse(new Response(
                $this->serializer->serialize($exception->getConstraintViolationList(), $format['key']),
                Response::HTTP_BAD_REQUEST,
                [
                    'Content-Type' => sprintf('%s; charset=utf-8', $format['value'][0]),
                    'X-Content-Type-Options' => 'nosniff',
                    'X-Frame-Options' => 'deny',
                ]
        ));
    }
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();
        if (!$exception instanceof ValidationException) {
            return;
        }

        $format = ErrorFormatGuesser::guessErrorFormat($event->getRequest(), $this->errorFormats);

        $event->setResponse(new Response(
                $this->serializer->serialize($exception->getConstraintViolationList(), $format['key']),
                Response::HTTP_BAD_REQUEST,
                [
                    'Content-Type' => sprintf('%s; charset=utf-8', $format['value'][0]),
                    'X-Content-Type-Options' => 'nosniff',
                    'X-Frame-Options' => 'deny',
                ]
        ));
    }
public function onKernelException ( GetResponseForExceptionEvent $ event ) : void { $ exception = $ event -> getException ( ) ; if ( ! $ exception instanceof ValidationException ) { return ; } $ format = ErrorFormatGuesser :: guessErrorFormat ( $ event -> getRequest ( ) , $ this -> errorFormats ) ; $ event -> setResponse ( new Response ( $ this -> serializer -> serialize ( $ exception -> getConstraintViolationList ( ) , $ format [ 'key' ] ) , Response :: HTTP_BAD_REQUEST , [ 'Content-Type' => sprintf ( '%s; charset=utf-8' , $ format [ 'value' ] [ 0 ] ) , 'X-Content-Type-Options' => 'nosniff' , 'X-Frame-Options' => 'deny' , ] ) ) ; }
Returns a list of violations normalized in the Hydra format.
Returns a list of violations normalized in the Hydra format .