Skip to content

Commit

Permalink
422 validation status code issue fixed
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
Muthukrishnan committed May 30, 2018
1 parent 24f374d commit 150f4f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/RequestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pearl\RequestValidate;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -91,11 +92,11 @@ protected function failedValidation(Validator $validator)
* Format the errors from the given Validator instance.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return array
* @return \Illuminate\Http\JsonResponse
*/
protected function formatErrors(Validator $validator)
{
return $validator->getMessageBag()->toArray();
return new JsonResponse($validator->getMessageBag()->toArray(), 422);
}

/**
Expand Down

0 comments on commit 150f4f2

Please sign in to comment.