I am trying to validate a simple DTO:
@Data
public class Dto {
@NotNull
private Integer anInt;
@AssertTrue
public boolean isIntCustomValid() {
return anInt == 123 || anInt == 999;
}
}
In my Controller, with @Valid. When anInt
is null, isIntCustomValid
is still validated and I get this error because anInt
is null:
HV000090: Unable to access
If I remove isIntCustomValid
, then @NotNull works correctly.
I want to validate these separately.
I tried using @GroupSequence
and @Groups
, which works, but I have to create empty marker interfaces which is does not seem like an elegant solution.