Spring Boot validation - one from two not null
问题 I'm trying to validate if one of two fields are not null in Spring Boot? I have set that in the method class for the main object: @NotNull(message = "Username field is required") private String username; @NotNull(message = "Email field is required") private String email; but that will require to have both fields not null. Then I went with custom validation described here https://lmonkiewicz.com/programming/get-noticed-2017/spring-boot-rest-request-validation/ but I wasn't able to get that