Top Description Methods
jakarta.validation

public Interface ConstraintViolation<T>

Type Parameters
<T>
the type of the root bean
Imports
jakarta.validation.metadata.ConstraintDescriptor

Describes a constraint violation. This object exposes the constraint violation context as well as the message describing the violation.
Author
Emmanuel Bernard

Method Summary

Modifier and TypeMethod and Description
public ConstraintDescriptor<?>

Returns:

constraint metadata
getConstraintDescriptor
()

Returns the constraint metadata reported to fail.

public Object[]

Returns:

parameters of the method or constructor invocation or null
getExecutableParameters
()

Returns an Object[] representing the constructor or method invocation arguments if the ConstraintViolation is returned after validating the method or constructor parameters.

public Object

Returns:

the method or constructor return value or null
getExecutableReturnValue
()

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

public Object

Returns:

the value failing to pass the constraint
getInvalidValue
()

Returns the value failing to pass the constraint.

public Object

Returns:

the leaf bean
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 or a container element constraint hosted on a property
  • 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 or a container element constraint hosted on a method parameter or return value
  • null if it is a constructor parameter or cross-parameter constraint or a container element constraint hosted on a constructor parameter
  • the object the constructor has created if it is a constructor return value constraint
public String

Returns:

the interpolated error message for this constraint violation
getMessage
()

public String

Returns:

the non-interpolated error message for this constraint violation
getMessageTemplate
()

public Path

Returns:

the property path to the value from rootBean
getPropertyPath
()

public T

Returns:

the validated object, the object hosting the validated element or null
getRootBean
()

Returns the root bean being validated.

public Class<T>

Returns:

the class of the root bean or of the object hosting the validated element
getRootBeanClass
()

Returns the class of the root bean being validated.

public <
the type of the object to be returned
U
>
U

Returns:

an instance of the specified class
unwrap
(Class<U>
the class of the object to be returned
type
)

Returns an instance of the specified type allowing access to provider-specific APIs.

Method Detail

getConstraintDescriptorback to summary
public ConstraintDescriptor<?> getConstraintDescriptor()

Returns the constraint metadata reported to fail. The returned instance is immutable.

Returns:ConstraintDescriptor<?>

constraint metadata

getExecutableParametersback to summary
public 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:Object[]

parameters of the method or constructor invocation or null

Since
1.1
getExecutableReturnValueback to summary
public 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:Object

the method or constructor return value or null

Since
1.1
getInvalidValueback to summary
public Object getInvalidValue()

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

Returns:Object

the value failing to pass the constraint

getLeafBeanback to summary
public 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 or a container element constraint hosted on a property
  • 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 or a container element constraint hosted on a method parameter or return value
  • null if it is a constructor parameter or cross-parameter constraint or a container element constraint hosted on a constructor parameter
  • the object the constructor has created if it is a constructor return value constraint
Returns:Object

the leaf bean

getMessageback to summary
public String getMessage()
Returns:String

the interpolated error message for this constraint violation

getMessageTemplateback to summary
public String getMessageTemplate()
Returns:String

the non-interpolated error message for this constraint violation

getPropertyPathback to summary
public Path getPropertyPath()
Returns:Path

the property path to the value from rootBean

getRootBeanback to summary
public T getRootBean()

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

Returns null when:

Returns:T

the validated object, the object hosting the validated element or null

getRootBeanClassback to summary
public 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:Class<T>

the class of the root bean or of the object hosting the validated element

unwrapback to summary
public <U> U unwrap(Class<U> type)

Returns an instance of the specified type allowing access to provider-specific APIs. If the Jakarta Validation provider implementation does not support the specified class, ValidationException is thrown.

Parameters
<U>
the type of the object to be returned
type:Class<U>

the class of the object to be returned

Returns:U

an instance of the specified class

Exceptions
ValidationException:
if the provider does not support the call
Since
1.1