Open joelharkes opened 5 years ago
I build a pr: it gets rejected telling me I should go here. I go here, nothing happens?
There are a lot of ways to control this, primarily, by overriding Illuminate\Foundation\Exceptions::invalidJson()
. A factory for validation exceptions isn't really the solution to this problem.
I maybe too quickly made a PR for this (see: https://github.com/laravel/framework/pull/27833/files). Let me explain the proposal.
Problem
Current issues with validation (Exception):
FormRequest
class. If you make dynamic rules and validate them directly it will use the defaultValidationException
format.Solution
The factory method (+interface/contract for it) for the exception is feasible because everywhere the exception is thrown there is aso the IOC container that can be used to instantiate this factory.
Users of laravel framework can than extend the
ValidationExceptionFactory
to inject a translation for theValidationException
and can overwrite the methods to return a sublcass ofValidationException
to provide additional formatting of the http response returned to the client.