I am trying to validate an input field that is supposed to contain (if not empty) a natural number (i.e. a positive non-zero integer: 1, 2, 3, ....)
I am using the following annotations:
@Digits(integer=10, fraction=0)
@Min(value = 1)
private Long number;
(Is this the best way to describe my constraint???)
When I submit a number such as 1.5 I get a VALIDATION MESSAGE which is good. However when I submit an input such as -1 I do not get any VALIDATION MESSAGE. What do I miss?
Thanks!
P.S. Since my (other) Hibernate annotations for this field were on the getter of the field, I just move these two annotations to the getter as well (instead of being on the actual field). Did not help.
EDIT
I just read I might need to add <mvc:annotation-driven />
to my XML. I did it, however while starting the server I am getting the exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc]
Offending resource: ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
I am not sure what it means and if I actually need (????) that annotation-driven tag... also, if I needed that annotation-driven tag in my xml, why did my other annotations (including one of the validation annotations) work without it?