Validation rule message in function format like wildcard #1483
popovicieduard
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the docs: https://preview.adonisjs.com/guides/validator/custom-messages#wild-card-callback
You can use a wildcard to format the messages.
I found myself writing tens of lines of code for every type of rule and field, what I tought of is using the same style as the wildcard in order to better format the rules, I know there is the micro templating (https://preview.adonisjs.com/guides/validator/custom-messages#micro-templating) thing but that doesn't suit every need.
In my opinion it would be way readable and easier to write rules with the suggested format from below.
let's say you want to show the message fields as snake_case.
With the current approach you can't do this, you can only access the passed options, but you can't really format them anymore.
current syntax:
instead, you would be able to do something like this:
Beta Was this translation helpful? Give feedback.
All reactions