Interface Validator
- All Superinterfaces:
jakarta.validation.Validator
- All Known Implementing Classes:
DefaultAnnotatedElementValidator
,DefaultValidator
public interface Validator
extends jakarta.validation.Validator
Extended version of the
Valid
interface for Micronaut's implementation.
The Validator.getConstraintsForClass(Class)
method is not supported by the implementation.
- Since:
- 1.2
- Author:
- graemerocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescription@NonNull ExecutableMethodValidator
Overridden variation that returns aExecutableMethodValidator
.static @NonNull Validator
Constructs a new default instance.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validate
(@NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, T object, @NonNull BeanValidationContext context) Validate the given introspection and object.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validate
(@NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, T object, @Nullable Class<?>... groups) Validate the given introspection and object.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validate
(T object, @NonNull BeanValidationContext validationContext) Validates all constraints onobject
.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validateProperty
(T object, @NonNull String propertyName, BeanValidationContext context) Validates all constraints placed on the property ofobject
namedpropertyName
.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validateProperty
(T object, @NonNull String propertyName, Class<?>... groups) <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validateValue
(@NonNull Class<T> beanType, @NonNull String propertyName, @Nullable Object value, BeanValidationContext context) Validates all constraints placed on the property namedpropertyName
of the classbeanType
would the property value bevalue
.<T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
validateValue
(@NonNull Class<T> beanType, @NonNull String propertyName, @Nullable Object value, Class<?>... groups) Methods inherited from interface jakarta.validation.Validator
getConstraintsForClass, unwrap
-
Field Details
-
ANN_VALID
Annotation used to define an object as valid. -
ANN_CONSTRAINT
Annotation used to define a constraint.
-
-
Method Details
-
forExecutables
Overridden variation that returns aExecutableMethodValidator
.- Specified by:
forExecutables
in interfacejakarta.validation.Validator
- Returns:
- The validator
-
validate
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull T object, Class<?>... groups) - Specified by:
validate
in interfacejakarta.validation.Validator
-
validate
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull T object, @NonNull @NonNull BeanValidationContext validationContext) Validates all constraints onobject
.- Type Parameters:
T
- the type of the object to validate- Parameters:
object
- object to validatevalidationContext
- The context- Returns:
- constraint violations or an empty set if none
- Throws:
IllegalArgumentException
- if object isnull
or ifnull
is passed to the varargs groupsjakarta.validation.ValidationException
- if a non recoverable error happens during the validation process
-
validate
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull @NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, @NonNull T object, @Nullable @Nullable Class<?>... groups) Validate the given introspection and object.- Type Parameters:
T
- The object type- Parameters:
introspection
- The introspectionobject
- The objectgroups
- The groups- Returns:
- The constraint violations
-
validate
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull @NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, @NonNull T object, @NonNull @NonNull BeanValidationContext context) Validate the given introspection and object.- Type Parameters:
T
- The object type- Parameters:
introspection
- The introspectionobject
- The objectcontext
- The context- Returns:
- The constraint violations
-
validateProperty
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateProperty(@NonNull T object, @NonNull @NonNull String propertyName, Class<?>... groups) - Specified by:
validateProperty
in interfacejakarta.validation.Validator
-
validateProperty
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateProperty(@NonNull T object, @NonNull @NonNull String propertyName, BeanValidationContext context) Validates all constraints placed on the property ofobject
namedpropertyName
.- Type Parameters:
T
- the type of the object to validate- Parameters:
object
- object to validatepropertyName
- property to validate (i.e. field and getter constraints)context
- The context- Returns:
- constraint violations or an empty set if none
- Throws:
IllegalArgumentException
- ifobject
isnull
, ifpropertyName
isnull
, empty or not a valid object property or ifnull
is passed to the varargs groupsjakarta.validation.ValidationException
- if a non recoverable error happens during the validation process
-
validateValue
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateValue(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull String propertyName, @Nullable @Nullable Object value, Class<?>... groups) - Specified by:
validateValue
in interfacejakarta.validation.Validator
-
validateValue
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateValue(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull String propertyName, @Nullable @Nullable Object value, BeanValidationContext context) Validates all constraints placed on the property namedpropertyName
of the classbeanType
would the property value bevalue
.ConstraintViolation
objects returnnull
forConstraintViolation.getRootBean()
andConstraintViolation.getLeafBean()
.- Type Parameters:
T
- the type of the object to validate- Parameters:
beanType
- the bean typepropertyName
- property to validatevalue
- property value to validatecontext
- The context- Returns:
- constraint violations or an empty set if none
- Throws:
IllegalArgumentException
- ifbeanType
isnull
, ifpropertyName
isnull
, empty or not a valid object property or ifnull
is passed to the varargs groupsjakarta.validation.ValidationException
- if a non recoverable error happens during the validation process
-
getInstance
Constructs a new default instance. Note that the returned instance will not contain managedConstraintValidator
instances and usingInject
should be preferred.- Returns:
- The validator.
-