Firstly, very thank you for your reply.
I also consider the validation group and group sequence,
but i think there are some difference for my need.
Code:
@NotBlank(groups = First.class)
@Size(min = 4, max = 30, groups = Second.class)
private String name;
@NotBlank(groups = First.class)
@Size(max = 100, groups = Second.class)
@Email(groups = Third.class)
private String mail;
@GroupSequence({ First.class, Second.class, Third.class})
interface All {
}
When the name is blank and the mail is "abc".
Only the @NotBlank at name, and @NotBlank at mail will be checked by JSR303,
Because the @NotBlank at name is invalid, so the Second and Third group
is not be checked.
But my need is @NotBlank at name and @NotBlank, @Size, @Email at mail should be checked.
Because the @NotBlank at name is invalid, so the @Size at name is not be checked,
and the @NotBlank,@Size at mail is valid, so the @Email at mail is be checked.
Is there a good way to implement my need by JSR303?