Closed leroy0211 closed 5 years ago
Hello @leroy0211,
This one is already built-in in the main package: https://github.com/phpro/api-problem#validationapiproblem
new ValidationApiProblem($errors);
You can wrap and throw an ExceptionApiProblem
or create your own ValidationFailedException
and add a transformer for that one.
Symfony Validator component has a built in feature to normalize a
ConstraintViolationListInterface
to an RFC7807 output. However, you need to do this by returning this yourself like so:It would be much nicer to throw an exception, because in the above example, it is very easy to mis the response status. And with an exception it doesn't.
Maybe something like:
Or does this package already has a solution for it?