I've a request with an Enum inside and I can validate it with @NotNull but if I try to insert @NotEmpty too it does not work. This is a sample of what I would like to achieve.
@NotNull
@NotEmpty
private MyEnum myEnum;
How can I make it works?
The javax @NotEmpty can only be applied CharSequence, Collection, Map or Array values (see documentation)
Empty and enum does not really make sense, except if you have an enum with an empty value, for example:
public enum MyEnum {
NOT_EMPTY("notEmpty"), EMPTY("");
}
So the question would be how to validate for specific enum values or subsets.
In that case you would have to define your own validation annotation.
nullthen the@NotNullwill kick in.