Better custom message composing #1800
mehmet-z-sonmez
started this conversation in
Feature Ideas
Replies: 1 comment 2 replies
-
Good bye class-validator. It was a good experience for me not 100% rely on open source projects unless they are baked by sponsors or very big projects. This project is a success returned to failure. Dont waste your time with this idle project. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
There is a need for better custom message composing especially for i18n purpose.
It would be great to have constraint metadata as a returned property. Currently, we can access constraint name, but cant have the supplied arguments within the decorator.
If we can get the argument(s) , in the example that is "30" then we would create custom message instead of using custom message for each decorator that is the only way and not the best way right now.
Returned Property Example:
constraints: { minLength: '30' }
For example; user may compose the following error message; {0} is the constraint name and {1} is the argument ('30' in this example)
Possible example custom error message template would be like this. Now we have {0} and {1} .
"minLength": "{0} must be longer than or equal to {1} characters",
I created a pull request #1697 but @NoNameProvided advised to discuss it before a pull request and returning a property would be better instead of a manipulated message. I agree too.
Beta Was this translation helpful? Give feedback.
All reactions