laravel+dingo: useful validation error messages

raw

README.rst

Our API only returned "The given data failed to pass validation." when data validation failed. I had to adjust AppServiceProvider.php to render the responses properly.

Make sure to send HTTP requests with

Accept: application/json

Search terms:

  • laravel validator json api validation error messages
  • dingo api exception handler json validation
raw

app/Providers/AppServiceProvider.php

1
2
3
4
5
6
7
8
    public function boot()
    {
        //...
        app('Dingo\Api\Exception\Handler')->register(
            function (\Illuminate\Validation\ValidationException $e) {
                return $e->getResponse();
            }
        );
Christian Weiske Christian Weiske
owner

History