@NotBlank
and @Email
both share "" as invalid value. You might consider adding some kind of conversion service which converts "" into Null and replace the @NotBlank
constraint with @NotNull
. Null doesn't trigger @Email
, but triggers @NotNull
only. Groups are not necessary in this scenario.
Regarding your second question, a constraint is per default in the group javax.validation.groups.Default
. You set your @Email
constraint explicitly in the group ValidInput.class
.