kristijanhusak / laravel-form-builder

Laravel Form builder for version 5+!
https://packagist.org/packages/kris/laravel-form-builder
MIT License
1.7k stars 296 forks source link

[BUG] Kind of exception thrown on validation error #521

Open kennaar opened 5 years ago

kennaar commented 5 years ago

Why does this package throw a Illuminate\Http\Exceptions\HttpResponseException when form validation fails? Laravel form request classes throw a Illuminate\Validation\ValidationException. Wouldn't it be better to throw that one instead to stay inline with the "defaul" laravel way?

rudiedirkx commented 5 years ago

That's a good point. And it takes a response, which we need, and it's handled well.

It's not a bug, but definitely an improvement. You want to make a PR? If so, don't forget about the tests: it_can_automatically_redirect_back_when_failing_verification and it_can_automatically_redirect_to_a_specified_destination_when_failing_verification.

Just be sure that all recent Laravel versions still work, since Laravel introduces breaking changes in minor releases. If ValidationException only exists since 5.7 (I've no idea), we need a HttpResponseException fallback.