I have this Laravel 9 API project and I can now return response whenever I inserted/updated successfully. But when it comes to validation in which I used FormRequest a separate file to validate inputs. My question is is there a "proper/safe way" to return validation errors as a json response?
as @frankielee said just set Accept in your header and if you want to customize the validation error
use ValidationException in Exceptions->Handler.php
Guys! thank you for your help! I solved it by modifying Exception/Handler.php error rendering. Got to solve 1 last problem, it seems like I cant catch & modify Internal Server Error ( 500xx) status code response.