Send custom JSON error response in Laravel

Ravi Teja
1 min readMar 22, 2019

Instead of using a validator, you can send custom JSON error responses in Laravel. If you are using axios library, the catch() method will grab the response.

if ($some_check_here) {
return response()->json([
'errors' => [ 'contact_type' => [ 'You must give either valid email or phone number' ] ] ], 422);
}

--

--