Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.15.2
Description
As of today the key/messages used by the annotated validators do not allow to receive custom arguments, since only the parameters defined by the annotation can be used. In order to improve that I suggest to add a parameter keyArgs to the validation annotations so it will be passed to the OGNL evaluator when it evaluates the key provided in the annotation. That way the following would be possible:
@Validations( requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "event.email", key = "validation-error.mandatory") keyArgs={"email","one","two"} } )
Then the key/message could be something like this:
validation-error.mandatory = The field ${getText(keyArgs[0])} is mandatory email= E-mail
And the result would be
The field E-mail is mandatory
It would allow to customize the message even further than it allows now. I suppose it would need to be implemented also in xml validations, but I haven't used them, so I don't what would be needed for that.