@Target({TYPE,METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy=io.xlate.validation.internal.constraintvalidators.ExpressionValidator.class)
@Repeatable(List.class)
public @interface Expression
Constraint to evaluate an arbitrary EL expression with the annotated target
available as 'self' in expressions. The EL expression must evaluate to
Boolean.TRUE in order for the annotated target to be valid.
- Author:
- Michael Edgar
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumValues allowed for exceptionalValue().static @interfaceDefines severalExpressionannotations on the same element. -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Value used in place of thevalue()expression's return when evaluation results in an exception being thrown.Class<?>[]String[]Name of the nodes to be identified in aConstraintViolationshould validation fail.String[]Class<? extends jakarta.validation.Payload>[]String[]The name to be used within thevalue()andwhen()expressions to refer to the target of the@Expressionannotation.jakarta.validation.ConstraintTargetWhen the constraint is placed on a method target, this determines whether the validation target is the method's return value or its parameters.A boolean EL expression used to determine if the expression given byvalue()should be checked.
-
Element Details
-
value
String valueA boolean expression evaluated to determine whether the constraint is valid. When the expression is true, it is considered valid. Else, it is considered invalid.- Returns:
- the expression to evaluate to determine the validity of the constraint
-
-
-
message
String message- Default:
- "expression `{value}` does not evaluate to true"
-
groups
Class<?>[] groups- Default:
- {}
-
payload
Class<? extends jakarta.validation.Payload>[] payload- Default:
- {}
-
validationAppliesTo
jakarta.validation.ConstraintTarget validationAppliesToWhen the constraint is placed on a method target, this determines whether the validation target is the method's return value or its parameters.- Since:
- 1.4
- Default:
- IMPLICIT
-
when
String whenA boolean EL expression used to determine if the expression given byvalue()should be checked. This expression is available to short-circuit the constraint validation of thisExpressionin scenarios when it should not apply, e.g. a value is null and the constraint only applies to non-null values.- Returns:
- the expression to evaluate to determine whether the constraint should be checked
- Default:
- ""
-
node
String[] nodeName of the nodes to be identified in aConstraintViolationshould validation fail. If more than one entry is present, each will be added to the violation as a separate property node.- Returns:
- the name of the nodes to be identified in a
ConstraintViolationshould validation fail.
- Default:
- {}
-
targetName
String targetNameThe name to be used within thevalue()andwhen()expressions to refer to the target of the@Expressionannotation.- Returns:
- the name to use for binding the annotation target within expressions
- Default:
- "self"
-
packageImports
String[] packageImportsThe packages to be imported to the EL context for evaluating the expressions invalue()andwhen(). All classes in the package will be imported.- Returns:
- the packages to be imported to the EL context during expression evaluation
- See Also:
-
ImportHandler.importPackage(String)
- Default:
- {}
-
classImports
String[] classImports- Returns:
- the classes to be imported to the EL context during expression evaluation
- See Also:
-
ImportHandler.importClass(String)
- Default:
- {}
-
staticImports
String[] staticImportsThe static member name, including the full class name, to be imported to the EL context for evaluating the expressions invalue()andwhen().- Returns:
- the static member names to be imported to the EL context during expression evaluation
- See Also:
-
ImportHandler.importStatic(String)
- Default:
- {}
-
exceptionalValue
Expression.ExceptionalValue exceptionalValueValue used in place of thevalue()expression's return when evaluation results in an exception being thrown.- Returns:
- value used in place of the result of the
value()expression - Since:
- 1.3
- Default:
- UNSET
-