Package org.openxava.annotations
Annotation Type EntityValidator
-
@Repeatable(EntityValidators.class) @Retention(RUNTIME) @Target(TYPE) @Constraint(validatedBy=EntityValidatorValidator.class) public @interface EntityValidator
This validator allows to define a validation at entity level.Applies to entities.
When you need to make a validation on several properties at a time, and that validation does not correspond logically with any of them, then you can use this type of validation.
Example:@Entity @EntityValidator(value=InvoiceDetailValidator.class, properties= { @PropertyValue(name="invoice"), @PropertyValue(name="oid"), @PropertyValue(name="product"), @PropertyValue(name="unitPrice") } ) public class InvoiceDetail { ...
EntityValidator
is also implemented as a Hibernate validation, therefore it's executed when you save using JPA or Hibernate API, with the exception of onlyOnCreate=true, in this last case the validation is only applied when you save with OpenXava (usingMapFacade
or standard OX actions).- Author:
- Javier Paniza
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class
value
Class that implements the validation logic.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>[]
groups
java.lang.String
message
The message to be shown if validation fails.boolean
onlyOnCreate
If true the validator is executed only when creating a new object, not when an existing object is modified.java.lang.Class<? extends javax.validation.Payload>[]
payload
PropertyValue[]
properties
To set values to the validator properties before executing it.
-
-
-
Element Detail
-
value
java.lang.Class value
Class that implements the validation logic. It has to be of typeIValidator
.
-
-
-
properties
PropertyValue[] properties
To set values to the validator properties before executing it.- Default:
- {}
-
-
-
message
java.lang.String message
The message to be shown if validation fails.The validator class have to implement
IWithMessage
to receive this message.
If not specified the message is not injected in the validator, in this case the validator should produce an appropriate default message.
You can specify an id of the messages i18n file using braces:message="{color_not_available}"
Or directly the message:message="That color is not available. This car can be only red or yellow"
- Default:
- ""
-
-