hibernate-validator

Hibernate Validation of Collections of Primitives

≡放荡痞女 提交于 2019-11-26 04:10:55
问题 I want to be able to do something like: @Email public List<String> getEmailAddresses() { return this.emailAddresses; } In other words, I want each item in the list to be validated as an email address. Of course, it is not acceptable to annotate a collection like this. Is there a way to do this? 回答1: Neither JSR-303 nor Hibernate Validator has any ready-made constraint that can validate each elements of Collection. One possible solution to address this issue is to create a custom

Cross field validation with Hibernate Validator (JSR 303)

心已入冬 提交于 2019-11-25 22:05:47
问题 Is there an implementation of (or third-party implementation for) cross field validation in Hibernate Validator 4.x? If not, what is the cleanest way to implement a cross field validator? As an example, how can you use the API to validate two bean properties are equal (such as validating a password field matches the password verify field). In annotations, I\'d expect something like: public class MyBean { @Size(min=6, max=50) private String pass; @Equals(property=\"pass\") private String