javax.validation.executable

Annotation Type ValidateOnExecution


  • @Target(value={CONSTRUCTOR,METHOD,TYPE,PACKAGE})
     @Retention(value=RUNTIME)
    public @interface ValidateOnExecution
    Expresses which executables (methods or constructors) should have their parameters and return value validated upon execution. Can be on executable (method, constructor) or type level (with the former taking precedence).

    If not present for a given executable, the default configuration from META-INF/validation.xml and finally the implicit default validated executable types (constructors and non-getters) are taken into account to determine whether a given executable is validated upon execution or not.

    The following describes the formal rules for deciding whether an executable is validated. They are applied in decreasing order:

    • the executable is validated if it is annotated with @ValidateOnExecution and the type attribute contains the executable type or ExecutableType.IMPLICIT. If the type attribute does neither contain the executable type nor IMPLICIT, the executable is not validated.
    • otherwise the executable is validated if the type (class, interface) on which it is declared is annotated with @ValidateOnExecution and the type attribute contains the executable type. If the type attribute contains IMPLICIT, then this rule is ignored and the behavior is equivalent to ValidateOnExecution not being present. If the type attribute does not contain the executable type, the executable is not validated.
    • otherwise the executable is validated if the global executable validation setting contains the executable type. If the global setting does not contain the executable type, the executable is not validated.
    • The rules above do not apply to methods overriding a superclass method or implementing an interface method. In this case, the method inherits the behavior of the method it overrides or implements. Out of the box, a conforming implementation raises a ValidationException if the overriding / implementing method hosts the ValidateOnExecution annotation.

    Note that you can exclude an executable from validation by making sure the rules above do not match or by annotating the executable with @ValidateOnExecution(NONE).

    Since:
    1.1
    Author:
    Emmanuel Bernard
    • Element Detail

      • type

        public abstract ExecutableType[] type
        List of executable types to be validated when called. Defaults to the types discovered implicitly (see ExecutableType.IMPLICIT).
        Default:
        javax.validation.executable.ExecutableType.IMPLICIT

Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/validation/executable/ValidateOnExecution.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : https://docs.oracle.com, ValidateOnExecution (Java(TM) EE 7 Specification APIs)

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.