Package jakarta.validation
Interface ConstraintViolation<T>
- 
- Type Parameters:
- T- the type of the root bean
 
 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 SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description ConstraintDescriptor<?>getConstraintDescriptor()Returns the constraint metadata reported to fail.Object[]getExecutableParameters()Returns anObject[]representing the constructor or method invocation arguments if theConstraintViolationis returned after validating the method or constructor parameters.ObjectgetExecutableReturnValue()Returns the return value of the constructor or method invocation if theConstraintViolationis returned after validating the method or constructor return value.ObjectgetInvalidValue()Returns the value failing to pass the constraint.ObjectgetLeafBean()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 propertynullwhen theConstraintViolationis returned after callingValidator.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 valuenullif 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 constraintStringgetMessage()StringgetMessageTemplate()PathgetPropertyPath()TgetRootBean()Returns the root bean being validated.Class<T>getRootBeanClass()Returns the class of the root bean being validated.<U> Uunwrap(Class<U> type)Returns an instance of the specified type allowing access to provider-specific APIs.
 
- 
- 
- 
Method Detail- 
getMessageString getMessage() - Returns:
- the interpolated error message for this constraint violation
 
 - 
getMessageTemplateString getMessageTemplate() - Returns:
- the non-interpolated error message for this constraint violation
 
 - 
getRootBeanT getRootBean() Returns the root bean being validated. For method validation, returns the object the method is executed on.Returns nullwhen:- the ConstraintViolationis returned after callingValidator.validateValue(Class, String, Object, Class[])
- the ConstraintViolationis returned after validating a constructor.
 - Returns:
- the validated object, the object hosting the validated element or null
 
- the 
 - 
getRootBeanClassClass<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
 
 - 
getLeafBeanObject 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
- nullwhen the- ConstraintViolationis 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
- nullif 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:
- the leaf bean
 
 - 
getExecutableParametersObject[] getExecutableParameters() Returns anObject[]representing the constructor or method invocation arguments if theConstraintViolationis returned after validating the method or constructor parameters. Returnsnullotherwise.- Returns:
- parameters of the method or constructor invocation or null
- Since:
- 1.1
 
 - 
getExecutableReturnValueObject getExecutableReturnValue() Returns the return value of the constructor or method invocation if theConstraintViolationis returned after validating the method or constructor return value.Returns nullif the method has no return value. Returnsnullotherwise.- Returns:
- the method or constructor return value or null
- Since:
- 1.1
 
 - 
getPropertyPathPath getPropertyPath() - Returns:
- the property path to the value from rootBean
 
 - 
getInvalidValueObject getInvalidValue() Returns the value failing to pass the constraint. For cross-parameter constraints, anObject[]representing the method invocation arguments is returned.- Returns:
- the value failing to pass the constraint
 
 - 
getConstraintDescriptorConstraintDescriptor<?> 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 Jakarta Bean Validation provider implementation does not support the specified class,ValidationExceptionis thrown.- Type Parameters:
- U- the type of the object to be returned
- 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
 
 
- 
 
-