@NotNull and @NotEmpty for same property

Viewed 2814

I am using spring boot.

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

For same property I am giving two annotations one is for null check another is for empty check.

@NotNull(message = "{email.notnull}")
@NotEmpty(message = "{email.notempty}")
private String email;

I am loading the error messages from properties file.

When I give email as empty then I am getting the error message from email.notempty only, but when I give email as null then email.notnull and email.notempty these two error messages are displaying, May I Know what is the mistake that I have done.

I should be able to see only null error when I have given null.

1 Answers
Related