Pass validation error dynamic parameters along with error message #12180
Unanswered
andreyselin
asked this question in
Q&A
Replies: 1 comment
-
you will have to use the validate function in this case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Hi!
My problem is mixing of validation and translation layers.
Currently validation errors are returned as message strings, which works well as static keys for i18n, but if validation rule returns string with dynamic parameters like "Min password length is 8 symbols", I don't have this length=8 parameter to pass down to i18n t function along with error message as a key.
In this case Im forced to pass t function to validation rule to create message in proper language during validation, which seems not a good practice.
Probably I'm having this problem due to defining validation rules outside the component (without t function) for optimization purposes.
Describe the solution you'd like
I'd like to have error parameters object with keys/values to pass to translation layer
Describe alternatives you've considered
The only alternative I found is passing i18n t function to rules (in both native validation and external validation libraries)
Beta Was this translation helpful? Give feedback.
All reactions