I am making the following call to my API routes using Postman everything works fine until I force a validation error. the error object returned doesn't contain the full list of validation errors instead it only has something like this:
{"message":"The given data was invalid.","errors":{"email":["validation.email"],"password":["validation.min.string"]}}
What I want is that instead of "validation.min.string" it should return the full error message.
Here is my controller method:
public function __invoke(Request $request)
{
$credentials = $request->validate([
'email' => 'required|email|max:255',
'password' => 'required|min:8'
]);
$credentials['status'] = true;
if (Auth::attempt($credentials)) {
return response()->json('login success!');
} else {
return response()->json('login failure!');
}
}
Here is the screen shot of the postman request
As par my comment:
resources/lang/en/validation.php
existsemail
and min
existsAs a side note:
You can move the folder lang
at the top level and it will still work.
So resources/lang/en
would become lang/en