Package jakarta.validation
Interface Validator
- 
public interface ValidatorValidates bean instances. Implementations of this interface must be thread-safe.- Author:
 - Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ExecutableValidatorforExecutables()Returns the contract for validating parameters and return values of methods and constructors.BeanDescriptorgetConstraintsForClass(java.lang.Class<?> clazz)Returns the descriptor object describing bean constraints.<T> Tunwrap(java.lang.Class<T> type)Returns an instance of the specified type allowing access to provider-specific APIs.<T> java.util.Set<ConstraintViolation<T>>validate(T object, java.lang.Class<?>... groups)Validates all constraints onobject.<T> java.util.Set<ConstraintViolation<T>>validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)Validates all constraints placed on the property ofobjectnamedpropertyName.<T> java.util.Set<ConstraintViolation<T>>validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups)Validates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue. 
 - 
 
- 
- 
Method Detail
- 
validate
<T> java.util.Set<ConstraintViolation<T>> validate(T object, java.lang.Class<?>... groups)
Validates all constraints onobject.- Type Parameters:
 T- the type of the object to validate- Parameters:
 object- object to validategroups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
 - constraint violations or an empty set if none
 - Throws:
 java.lang.IllegalArgumentException- if object isnullor ifnullis passed to the varargs groupsValidationException- if a non recoverable error happens during the validation process
 
- 
validateProperty
<T> java.util.Set<ConstraintViolation<T>> validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)
Validates all constraints placed on the property ofobjectnamedpropertyName.- Type Parameters:
 T- the type of the object to validate- Parameters:
 object- object to validatepropertyName- property to validate (i.e. field and getter constraints)groups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
 - constraint violations or an empty set if none
 - Throws:
 java.lang.IllegalArgumentException- ifobjectisnull, ifpropertyNameisnull, empty or not a valid object property or ifnullis passed to the varargs groupsValidationException- if a non recoverable error happens during the validation process
 
- 
validateValue
<T> java.util.Set<ConstraintViolation<T>> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups)
Validates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue.ConstraintViolationobjects returnnullforConstraintViolation.getRootBean()andConstraintViolation.getLeafBean().- Type Parameters:
 T- the type of the object to validate- Parameters:
 beanType- the bean typepropertyName- property to validatevalue- property value to validategroups- the group or list of groups targeted for validation (defaults toDefault).- Returns:
 - constraint violations or an empty set if none
 - Throws:
 java.lang.IllegalArgumentException- ifbeanTypeisnull, ifpropertyNameisnull, empty or not a valid object property or ifnullis passed to the varargs groupsValidationException- if a non recoverable error happens during the validation process
 
- 
getConstraintsForClass
BeanDescriptor getConstraintsForClass(java.lang.Class<?> clazz)
Returns the descriptor object describing bean constraints.The returned object (and associated objects including
ConstraintDescriptors) are immutable.- Parameters:
 clazz- class or interface type evaluated- Returns:
 - the bean descriptor for the specified class
 - Throws:
 java.lang.IllegalArgumentException- if clazz isnullValidationException- if a non recoverable error happens during the metadata discovery or if some constraints are invalid.
 
- 
unwrap
<T> T unwrap(java.lang.Class<T> 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,
ValidationExceptionis thrown.- Type Parameters:
 T- 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
 
- 
forExecutables
ExecutableValidator forExecutables()
Returns the contract for validating parameters and return values of methods and constructors.- Returns:
 - contract for method and constructor validation
 - Since:
 - 1.1
 
 
 - 
 
 -