Answer the question
In order to leave comments, you need to log in
ValidationException vs CustomException?
Hello. I write in laravel, SPA.
Actually, I translate all exceptions into my own, inheriting ApiException. I display them in json with id, meta parameters.
The site has a chat. The user sends a message and it is validated by the validator, and then some custom checks are added. How should it all be?
The options I could come up with, but I suspect there are others:
1, like now) ->validate everything you can and then add custom checks, throwing an ApiException if something is wrong. As a result, two different types of errors come out: id: validation_exception, where errors are indicated in meta by the field name immediately in the translation, and id: some_custom_error_name, where nothing is indicated in meta at all.
2) ->validate only basic things, such as bail required type, and everything else, including, for example, the maximum message length - in custom
Is there any centralized, correct solution? The front on Vue, the entire SPA site, I would also like to have translations on the front
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question