Reputation: 10147
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
Upvotes: 3
Views: 2202
Reputation: 3422
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;
}
}
Upvotes: 6