I using the following property value injection. How I can add a less than validation to this operation.
I mean I want to set a validation the user.maxpassiveday property value has not to be less than 100 lets say.
@Value("${user.maxpassiveday}")
int maxpassiveday;
Using Spring 3.1.1 version
You can also use @Value on setter method:
int maxpassiveday;
@Value("${user.maxpassiveday}")
public void setMaxPassiveDay(final String maxpassiveday) {
int tmp = Integer.parseInt(maxpassiveday);
if (tmp < 100) {
this.maxpassiveday = tmp;
}
}
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