public interface Validator
Modifier and Type | Method and Description |
---|---|
ExecutableValidator |
forExecutables()
Returns the contract for validating parameters and return values of methods
and constructors.
|
BeanDescriptor |
getConstraintsForClass(java.lang.Class<?> clazz)
Returns the descriptor object describing bean constraints.
|
<T> T |
unwrap(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 on
object . |
<T> java.util.Set<ConstraintViolation<T>> |
validateProperty(T object,
java.lang.String propertyName,
java.lang.Class<?>... groups)
Validates all constraints placed on the property of
object
named propertyName . |
<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 named
propertyName
of the class beanType would the property value be value . |
<T> java.util.Set<ConstraintViolation<T>> validate(T object, java.lang.Class<?>... groups)
object
.T
- the type of the object to validateobject
- object to validategroups
- the group or list of groups targeted for validation (defaults to
Default
)java.lang.IllegalArgumentException
- if object is null
or if null
is passed to the varargs groupsValidationException
- if a non recoverable error happens
during the validation process<T> java.util.Set<ConstraintViolation<T>> validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)
object
named propertyName
.T
- the type of the object to validateobject
- object to validatepropertyName
- property to validate (i.e. field and getter constraints)groups
- the group or list of groups targeted for validation (defaults to
Default
)java.lang.IllegalArgumentException
- if object
is null
,
if propertyName
is null
, empty or not a valid object property
or if null
is passed to the varargs groupsValidationException
- if a non recoverable error happens
during the validation process<T> java.util.Set<ConstraintViolation<T>> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups)
propertyName
of the class beanType
would the property value be value
.
ConstraintViolation
objects return null
for
ConstraintViolation.getRootBean()
and
ConstraintViolation.getLeafBean()
.
T
- the type of the object to validatebeanType
- the bean typepropertyName
- property to validatevalue
- property value to validategroups
- the group or list of groups targeted for validation (defaults to
Default
).java.lang.IllegalArgumentException
- if beanType
is null
,
if propertyName
is null
, empty or not a valid object property
or if null
is passed to the varargs groupsValidationException
- if a non recoverable error happens
during the validation processBeanDescriptor getConstraintsForClass(java.lang.Class<?> clazz)
The returned object (and associated objects including
ConstraintDescriptor
s) are immutable.
clazz
- class or interface type evaluatedjava.lang.IllegalArgumentException
- if clazz is null
ValidationException
- if a non recoverable error happens
during the metadata discovery or if some
constraints are invalid.<T> T unwrap(java.lang.Class<T> type)
If the Jakarta Bean Validation provider implementation does not support
the specified class, ValidationException
is thrown.
T
- the type of the object to be returnedtype
- the class of the object to be returnedValidationException
- if the provider does not support the callExecutableValidator forExecutables()