-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic validation error messages #473
Comments
you could do this:
|
How should that work? Where should I define the |
Ok, you have pushed me into the right direction. You can pass the functions into the rule config, i.e.
and it works, indeed. However, I think this is an abuse of what rule's config has been designed for. And it does not solve the situation when an async function is used in |
Note that if the thing you're trying to compute dynamically is in the object the rules apply to you can use this: .withMessage('Something or other: ${$object.thePropertyNeeded}') |
There should be something like Then, Now, the validation code works with arguments , instead of single argument in the form of |
FYI this requirement is addressed in Aurelia 2. In Aurelia 2 you can create your own custom rule class. This gives the encapsulation, as @PetrMotlicek suggests. Every rule has an |
I'm submitting a feature request
Currently, it is impossible to create a dynamic validation error message. For example, I want to validate IBAN account number. I configure the rule as follows:
The validation message could be much more informative, for example
Given IBAN number has cheksum 34 but it should be 56
.What about allowing to pass a callback that will generate a validation message based on given value? This should solve all of the cases where the validation message should be built based on the given value or something else dynamic.
OR it should be possible to define special parameters for message in addition to existing
$displayName
and$value
, e.g.What do you think?
The text was updated successfully, but these errors were encountered: