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(Class<?> clazz)
Returns the descriptor object describing bean constraints.
|
<T> T |
unwrap(Class<T> type)
Returns an instance of the specified type allowing access to
provider-specific APIs.
|
<T> Set<ConstraintViolation<T>> |
validate(T object,
Class<?>... groups)
Validates all constraints on
object . |
<T> Set<ConstraintViolation<T>> |
validateProperty(T object,
String propertyName,
Class<?>... groups)
Validates all constraints placed on the property of
object
named propertyName . |
<T> Set<ConstraintViolation<T>> |
validateValue(Class<T> beanType,
String propertyName,
Object value,
Class<?>... groups)
Validates all constraints placed on the property named
propertyName
of the class beanType would the property value be value . |
<T> Set<ConstraintViolation<T>> validate(T object, 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
)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> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, 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
)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> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, 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
).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(Class<?> clazz)
The returned object (and associated objects including
ConstraintDescriptor
s) are immutable.
clazz
- class or interface type evaluatedIllegalArgumentException
- if clazz is null
ValidationException
- if a non recoverable error happens
during the metadata discovery or if some
constraints are invalid.<T> T unwrap(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()
Comments to: bean-validation-dev@eclipse.org.
Copyright © 2019,2020 Eclipse Foundation.
Use is subject to EFSL; this spec is based on material that is licensed under the Apache License, version 2.0.