Disable request validation redirect in Laravel 5.4

You can try like this

Include use first as below in your form request

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;

and then

protected function failedValidation(Validator $validator) {
        throw new HttpResponseException(response()->json($validator->errors(), 422));
    }

now if you try to validate then it will return like

{
"title": [
"The  title field is required."
]
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)