i have a field in my spring bean (managed bean with jsf) and i am validating on it's length with the @Size annotation using JSR303 bean validation as follows:
@Size(min = 7, max = 15, message = "{password.range}")
private String newPassword;
and i was wondering how to read the min and max values from property file, please advise.
New answer
It is not possible with he standard JSR 303 Validatators. The problem is, that the values in annotations are compile time values, but the values in properties are only available at runtime.
Of course you can write your own JSR-303 Validators that read the value from the properties file while validatation.
So that you can use it this way:
@MySize(minKey = "password.min", maxKey = "password.max", message = "{password.range}")
The MySizeValidator
uses the minKey
to read that value from a properties file, and then validate the current value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With