laravel failed validation response code example
Example 1: return response at failedValidation() in request laravel
protected function failedValidation(Validator $validator) {
throw new HttpResponseException(response()->json($validator->errors()->all(), 422));
}
Example 2: return response at failedValidation() in request laravel
protected function failedValidation(Validator $validator)
{
throw new HttpResponseException(response()->json([
'errors' => $validator->errors(),
'status' => false
], 422));
}