Is there a way to return Form Request erros as a json?
I am making an API to AngularJS, and I am having problems with the error flags
Here is my rules:
class CreateProductRequest extends Request
{
public function rules()
{
return [
'code'=>'required|unique:products',
'style'=>'required|max:12',
'measure'=>'required|max:12',
];
}
This is the response from CreateProductRequest
{
code: [0: "Code is required"],
style:[0: "Style is required"],
measure:[ 0: "Measure is required"]
}
I want the same result as $validator->errors()->all() on the controller, like this:
"messages": [
"Code is required",
"Style is required",
"Measure is required"
]
How can I get this result from Form Request?
Laravel version: master