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
Fields -
Method Summary
Modifier and TypeMethodDescription@NonNull ExecutableMethodValidatorOverridden variation that returns aExecutableMethodValidator.static @NonNull ValidatorConstructs 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 ofobjectnamedpropertyName.<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 namedpropertyNameof the classbeanTypewould 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:
forExecutablesin interfacejakarta.validation.Validator- Returns:
- The validator
-
validate
@NonNull <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull T object, Class<?>... groups) - Specified by:
validatein 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 isnullor ifnullis 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:
validatePropertyin 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 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)context- The context- Returns:
- constraint violations or an empty set if none
- Throws:
IllegalArgumentException- ifobjectisnull, ifpropertyNameisnull, empty or not a valid object property or ifnullis 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:
validateValuein 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 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 validatecontext- The context- Returns:
- constraint violations or an empty set if none
- Throws:
IllegalArgumentException- ifbeanTypeisnull, ifpropertyNameisnull, empty or not a valid object property or ifnullis 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 managedConstraintValidatorinstances and usingInjectshould be preferred.- Returns:
- The validator.
-