user536161
user536161

Reputation: 69

how can i write rule with hibernate validator : field1 not null or field2 not null

public class User {
    @NotBlank
    private String name;
    @???
    private String email;
    @???
    private String mobile;
}

how can i write rule with hibernate validator(@???), like this code:

StringUtils.hasText(email) || StringUtils.hasText(mobile)

Upvotes: 0

Views: 24

Answers (1)

Hardy
Hardy

Reputation: 19109

You need to look at how to implement class level constraints. This feature is described in the Bean Validation specification as well as the Hibernate Validator online docs.

Upvotes: 1

Related Questions