Annotation Type Expression


@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
  • Element Details

    • value

      String value
      A 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 validationAppliesTo
      When 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 when
      A boolean EL expression used to determine if the expression given by value() should be checked. This expression is available to short-circuit the constraint validation of this Expression in 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[] node
      Name of the nodes to be identified in a ConstraintViolation should 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 ConstraintViolation should validation fail.
      Default:
      {}
    • targetName

      String targetName
      The name to be used within the value() and when() expressions to refer to the target of the @Expression annotation.
      Returns:
      the name to use for binding the annotation target within expressions
      Default:
      "self"
    • packageImports

      String[] packageImports
      The packages to be imported to the EL context for evaluating the expressions in value() and when(). 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
      The classes to be imported to the EL context for evaluating the expressions in value() and when().
      Returns:
      the classes to be imported to the EL context during expression evaluation
      See Also:
      • ImportHandler.importClass(String)
      Default:
      {}
    • staticImports

      String[] staticImports
      The static member name, including the full class name, to be imported to the EL context for evaluating the expressions in value() and when().
      Returns:
      the static member names to be imported to the EL context during expression evaluation
      See Also:
      • ImportHandler.importStatic(String)
      Default:
      {}
    • exceptionalValue

      Expression.ExceptionalValue exceptionalValue
      Value used in place of the value() 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