Using laravel 5.6, I currently, I get a 422 JSON response like this when a validation error occurs using $request->validate($rules)
:
{
"error": {
"isbn": [
"The isbn field is required."
],
"price": [
"The price field is required."
]
}
}
Instead, I expect it to be:
{
"errors": {
"isbn": [
"The isbn field is required."
],
"price": [
"The price field is required."
]
}
}
I noticed that the defaults in the RegisterController do return the plural of error when the validator is called with return Validator::make($data, $rules)
...
Why do I get the singular form with $request->validate($rules)
?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire