Annotation Type GwtValidation
-
@Documented @Target(TYPE) @Retention(RUNTIME) public @interface GwtValidation
Annotates ajavax.validation.Validatorexplicitly listing the classes that can be validated in GWT.Define the Validator you want, explicitly listing the classes and groups you want to validate.
@GwtValidation(value = {MyBean.class, MyOther.class},
groups = {Default.class, OtherGroup.class}) public interface MyValidator extends javax.validation.Validator { }Create and use the validator.
MyValidator validator = GWT.create(MyValidator.class); MyBean bean = new MyBean(); ... Set<ConstraintViolation<MyBean>> violations = validator.validate(bean);
You must list all validation groups you are using (as well as groups making up a group sequence)– unless you are only using the Default group, in which case you may omit the "groups" field of the
GwtValidationannotation.NOTE: Validation is done using only the Constraints found on the Classes listed in the annotation. If you have
class MyBean { @Null String getName() { return name; } } class MySubBean extends MyBean { @Size(min = 5) String getName() { return super.getName(); } }And then create your
ValidatorFactoryusing@GwtValidation(MyBean.class, MyOther.class)}
but call validator with the subclass like
MySubBean bean = new MySubBean(); Set<ConstraintViolation<MyBean>> violations = validator.validate(bean);
The
Sizeconstraint will not be validated.Instead make sure you list the all BeanTypes that will be directly validated in the
GwtValidationannotation.
-
-
Element Detail
-
value
Class<?>[] value
The list of Classes which can be validated by the annotatedValidator.- Returns:
- array of classes
-
-
-
groups
Class<?>[] groups
The list of Groups which can be processed by the annotatedValidator. The default value isDefault. An empty array is illegal.- Returns:
- array of classes
- Default:
- {javax.validation.groups.Default.class}
-
-
-
reflect
Class<?>[] reflect
The list of Classes which can be used a reflection getter, if empty all values are taken.- Returns:
- array of classes
- Default:
- {}
-
-