First of all, this is not a Spring annotation-based check, it is a JSR 303 Bean Validation implemented, for example, using Hibernate Validation. This is really not Spring related /
You cannot combine annotations along the OR path.
But there is a simple workaround for a non-zero constraint, since the most basic checks take null as valid input (so you often need to combine the basic options and optional @NotNull if you want to have "normal" "behavior, but not about than you asked).
For example: @javax.validation.constraints.Size accept null as valid input.
So you need to use @Size(min=1) instead of @NotEmpty in your case.
BTW: Not @NotEmpty - it's just a combination of @NotNull and @Size(min = 1)
* except that you implement it yourself.
Ralph
source share