It’s nice that we can reuse our JPA annotations for validation. But the chances are that not all validation that we want can be expressed in JPA annotations. For that reason, ExtVal offers a set of extra annotations that we can add to our beans to complement the implicit validation constraints that ExtVal derives from JPA annotations. These annotations are a part of the myfaces-extval-property-validation-1.2.x.jar
library. For example, if we want to add a minimum length to the lastName
field, we could use the @Length
annotation as follows:
@Length(minimum = 5)
@Column(name = "LAST_NAME", nullable = false, length = 30)
private String lastName;
Note that if, for some reason, we couldn’t use the length = 30
setting on the @Column
annotation, the @Length
annotation also has a maximum property that can be set. The @Length
annotation can be imported from the org.apache.myfaces.extensions.validator.baseval.annotation
package, which is where the other annotations that...