I would like to use Java Bean Validation to validate an Integer. It is a validation of multiple validations.
I'm currently using Spring Boot and validation, and system is using a @RestController
where I'm receiving the post-call.
public Person addPerson(@RequestBody @Validated Person Person) {/*the code*/}
I would like the age to be validated, where these values are valid:
age == null or age == 0 or (age >= 15 and age <= 80)
public class Person {
private Integer age;
}
I would like to be able to use the current validation constraints of java. Do I need to implement my own constraint annotation ?
This would be nice, but this does not work:
public class Person {
@Null
@Range(min=0, max=0)
@Range(min=15, max = 80)
private Integer age;
}