I am using Laravel request to validate in my controller the requested data
and here is my request file data
I am facing two challanges
By defalut it is returning like that
but I want like below SS
-To custom message
Laravel Documents customizing-the-error-messages
-To return a single error message
//In Request
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;
protected function failedValidation(Validator $validator)
{
throw new HttpResponseException(response()->json([
'success' => false,
'message' =>$validator->errors()->first(),
'data' => null,
], 422));
}