dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

Show errors for ValidationException #1510

Closed jianfengye closed 6 years ago

jianfengye commented 6 years ago

I got the same issue like https://github.com/dingo/api/issues/1496

And I check Laravel source Code

ValidateException has errors() method, it will show which field has validete error. And dingo/api‘s :error does not got this errors, that will make user unreachable the true validate error.

so I add this pr for show errors for ValidationException. and the response will like that: image

keyganker commented 6 years ago

@thilanga @jianfengye This PR cause error under laravel 5.2, 5.3, 5.4, because the ValidationException->errors method doesn't exists before laravel 5.5

And I have fixed this in #1549