How to handle integer field on string payload request in spring boot

Solution for How to handle integer field on string payload request in spring boot
is Given Below:

I am having a problem in handling a payload request with string type on an integer field.

Example payloads:

case 1:

{
  age: "1" // success
}

case 2:

{
  age: "1TEST"
}

// response is 1 as shown here: https://i.imgur.com/0eibDTz.png

I expect case#2 as an error with message & error json object.

Here is my entity:

@Entity
@Table(name = "students")
public class Student {

   @NotNull
   @Column(name = "age")
   @Positive
   @Digits(fraction = 0, integer = 10, message ="add a digit msg")
   private int age;

  // more codes below
}

I can handle this exception if I change it to private String age and then convert it to integer since data type in my database for age is integer.

Now, how can I handle this if I put age as int?

This question is related to my previous question.