In laravel 5.4, when using $this->validate()
function, it will give the default errors format with 422 status code as below.
{
"username": [
"The username field is required."
],
"email": [
"The email field is required."
],
"fullname": [
"The fullname field is required."
]
}
As refer to docs and this post,
I try to come with solution on override App\Http\Controllers\Controller
on two methods as to get the below output with 400 status code.
[
"The username field is required.",
"The email field is required.",
"The fullname field is required."
]