To validate a Integer field in Request bean, I used @range (min=0,max=99999999,message="invalid") and @digits().
they are throwing the error
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Numeric value (1111118493411) out of range of int;
How do I handle this in my request layer itself to restrict the user from entering more than 10 digits
@JsonProperty(value = "qty", required = true)
@NotNull
@Range(min=0, max=999999999 , message = "invalid")
private Integer qty;
I wish to throw an error stating invalid if the user enters more than 10 digits.
Max int value is 2,147,483,647
in java. You can see in this answer. Your value is bigger than max int value. So you should change qty's class field type(example long).