Scenario
When calling an external API and receiving an error response, I want to wrap the error as a ValidationException so the frontend can display it the same way as form validation errors.
Solution
| |
withMessages() accepts the same format as Validator errors — the key is the field name and the value is an array of error messages. The JSON structure the frontend receives will be identical to a regular validation failure.
