The Bean Validation API specifies a number of validations that can be specified on attributes on the beans. Take a look at the following listing:
@Size(min = 6, message = "Enter at least 6 characters") private String name; @Size(min = 6, message = "Enter at least 6 characters") private String userId; @Size(min = 8, message = "Enter at least 8 characters") private String password; @Size(min = 8, message = "Enter at least 8 characters") private String password2;
An important thing to note are as follows:
- @Size(min = 6, message = "Enter at least 6 characters") : This specifies that the field should at least have six characters. If the validation does not pass, the text from the message attribute is used ...