javax.validation

Interface ConstraintViolation<T>


  • public interface ConstraintViolation<T>
    Describes a constraint violation. This object exposes the constraint violation context as well as the message describing the violation.
    Author:
    Emmanuel Bernard
    • Method Detail

      • getMessage

        String getMessage()
        Returns:
        the interpolated error message for this constraint violation
      • getMessageTemplate

        String getMessageTemplate()
        Returns:
        the non-interpolated error message for this constraint violation
      • getRootBean

        T getRootBean()
        Returns the root bean being validated. For method validation, returns the object the method is executed on.

        Returns null when:

        Returns:
        the validated object, the object hosting the validated element or null
      • getRootBeanClass

        Class<T> getRootBeanClass()
        Returns the class of the root bean being validated. For method validation, this is the object class the method is executed on. For constructor validation, this is the class the constructor is declared on.
        Returns:
        the class of the root bean or of the object hosting the validated element
      • getLeafBean

        Object getLeafBean()
        Returns:
        • the bean instance the constraint is applied on if it is a bean constraint
        • the bean instance hosting the property the constraint is applied on if it is a property constraint
        • null when the ConstraintViolation is returned after calling Validator.validateValue(Class, String, Object, Class[])
        • the object the method is executed on if it is a method parameter, cross-parameter or return value constraint
        • null if it is a constructor parameter or cross-parameter constraint
        • the object the constructor has created if it is a constructor return value constraint
        Returns:
        the leaf bean
      • getExecutableParameters

        Object[] getExecutableParameters()
        Returns an Object[] representing the constructor or method invocation arguments if the ConstraintViolation is returned after validating the method or constructor parameters. Returns null otherwise.
        Returns:
        parameters of the method or constructor invocation or null
        Since:
        1.1
      • getExecutableReturnValue

        Object getExecutableReturnValue()
        Returns the return value of the constructor or method invocation if the ConstraintViolation is returned after validating the method or constructor return value.

        Returns null if the method has no return value. Returns null otherwise.

        Returns:
        the method or constructor return value or null
        Since:
        1.1
      • getPropertyPath

        Path getPropertyPath()
        Returns:
        the property path to the value from rootBean
      • getInvalidValue

        Object getInvalidValue()
        Returns the value failing to pass the constraint. For cross-parameter constraints, an Object[] representing the method invocation arguments is returned.
        Returns:
        the value failing to pass the constraint
      • getConstraintDescriptor

        ConstraintDescriptor<?> getConstraintDescriptor()
        Returns the constraint metadata reported to fail. The returned instance is immutable.
        Returns:
        constraint metadata
      • unwrap

        <U> U unwrap(Class<U> type)
        Returns an instance of the specified type allowing access to provider-specific APIs. If the Bean Validation provider implementation does not support the specified class, ValidationException is thrown.
        Parameters:
        type - the class of the object to be returned
        Returns:
        an instance of the specified class
        Throws:
        ValidationException - if the provider does not support the call
        Since:
        1.1

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/ConstraintViolation.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, ConstraintViolation (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.