Class MicronautHibernateValidator

java.lang.Object
io.micronaut.validation.validator.DefaultValidator
io.micronaut.configuration.hibernate.validator.MicronautHibernateValidator
All Implemented Interfaces:
io.micronaut.inject.annotation.AnnotatedElementValidator, io.micronaut.inject.validation.BeanDefinitionValidator, io.micronaut.validation.validator.ExecutableMethodValidator, io.micronaut.validation.validator.ReactiveValidator, io.micronaut.validation.validator.Validator, jakarta.validation.executable.ExecutableValidator, jakarta.validation.Validator

@Singleton @Primary @Requires(property="micronaut.validator.enabled", value="true", defaultValue="true") @Replaces(io.micronaut.validation.validator.DefaultValidator.class) public class MicronautHibernateValidator extends io.micronaut.validation.validator.DefaultValidator
Replaces Micronaut Validator with Hibernate backed implementation.
Since:
2.0.0
Author:
graemerocher
  • Field Summary

    Fields inherited from interface io.micronaut.inject.validation.BeanDefinitionValidator

    DEFAULT

    Fields inherited from interface io.micronaut.validation.validator.Validator

    ANN_CONSTRAINT, ANN_VALID
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MicronautHibernateValidator(jakarta.validation.ValidatorFactory validatorFactory, @NonNull io.micronaut.validation.validator.ValidatorConfiguration configuration)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.validation.metadata.BeanDescriptor
     
    <T> T
    unwrap(Class<T> type)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validate(T object, @Nullable Class<?>... groups)
     
    <T> void
    validateBean(@NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull io.micronaut.inject.BeanDefinition<T> definition, T bean)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validateConstructorParameters(@NonNull Constructor<? extends T> constructor, @NonNull Object[] parameterValues, @Nullable Class<?>... groups)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validateConstructorReturnValue(@NonNull Constructor<? extends T> constructor, T createdObject, @Nullable Class<?>... groups)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validateProperty(T object, @NonNull String propertyName, @Nullable Class<?>... groups)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validateReturnValue(T object, @NonNull Method method, @Nullable Object returnValue, @Nullable Class<?>... groups)
     
    <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>>
    validateValue(@NonNull Class<T> beanType, @NonNull String propertyName, @Nullable Object value, @Nullable Class<?>... groups)
     

    Methods inherited from class io.micronaut.validation.validator.DefaultValidator

    createValid, forExecutables, getBeanIntrospection, getBeanIntrospection, getBeanIntrospection, getBeanIntrospector, requireNonEmpty, requireNonNull, validate, validate, validate, validateBeanArgument, validateCompletionStage, validateConstructorParameters, validateConstructorParameters, validateConstructorParameters, validatedAnnotatedElement, validateParameters, validateParameters, validateParameters, validateParameters, validateProperty, validatePublisher, validateReturnValue, validateReturnValue, validateValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MicronautHibernateValidator

      protected MicronautHibernateValidator(jakarta.validation.ValidatorFactory validatorFactory, @NonNull @NonNull io.micronaut.validation.validator.ValidatorConfiguration configuration)
      Default constructor.
      Parameters:
      validatorFactory - The validator factory
      configuration - The validator configuration
  • Method Details

    • validate

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validate(@NonNull T object, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validate in interface io.micronaut.validation.validator.Validator
      Specified by:
      validate in interface jakarta.validation.Validator
      Overrides:
      validate in class io.micronaut.validation.validator.DefaultValidator
    • validateProperty

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateProperty(@NonNull T object, @NonNull @NonNull String propertyName, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validateProperty in interface io.micronaut.validation.validator.Validator
      Specified by:
      validateProperty in interface jakarta.validation.Validator
      Overrides:
      validateProperty in class io.micronaut.validation.validator.DefaultValidator
    • validateValue

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateValue(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull String propertyName, @Nullable @Nullable Object value, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validateValue in interface io.micronaut.validation.validator.Validator
      Specified by:
      validateValue in interface jakarta.validation.Validator
      Overrides:
      validateValue in class io.micronaut.validation.validator.DefaultValidator
    • getConstraintsForClass

      public jakarta.validation.metadata.BeanDescriptor getConstraintsForClass(Class<?> clazz)
      Specified by:
      getConstraintsForClass in interface jakarta.validation.Validator
      Overrides:
      getConstraintsForClass in class io.micronaut.validation.validator.DefaultValidator
    • unwrap

      public <T> T unwrap(Class<T> type)
      Specified by:
      unwrap in interface jakarta.validation.Validator
      Overrides:
      unwrap in class io.micronaut.validation.validator.DefaultValidator
    • validateReturnValue

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateReturnValue(@NonNull T object, @NonNull @NonNull Method method, @Nullable @Nullable Object returnValue, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validateReturnValue in interface io.micronaut.validation.validator.ExecutableMethodValidator
      Specified by:
      validateReturnValue in interface jakarta.validation.executable.ExecutableValidator
      Overrides:
      validateReturnValue in class io.micronaut.validation.validator.DefaultValidator
    • validateConstructorParameters

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateConstructorParameters(@NonNull @NonNull Constructor<? extends T> constructor, @NonNull @NonNull Object[] parameterValues, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validateConstructorParameters in interface io.micronaut.validation.validator.ExecutableMethodValidator
      Specified by:
      validateConstructorParameters in interface jakarta.validation.executable.ExecutableValidator
      Overrides:
      validateConstructorParameters in class io.micronaut.validation.validator.DefaultValidator
    • validateConstructorReturnValue

      @NonNull public <T> @NonNull Set<jakarta.validation.ConstraintViolation<T>> validateConstructorReturnValue(@NonNull @NonNull Constructor<? extends T> constructor, @NonNull T createdObject, @Nullable @Nullable Class<?>... groups)
      Specified by:
      validateConstructorReturnValue in interface io.micronaut.validation.validator.ExecutableMethodValidator
      Specified by:
      validateConstructorReturnValue in interface jakarta.validation.executable.ExecutableValidator
      Overrides:
      validateConstructorReturnValue in class io.micronaut.validation.validator.DefaultValidator
    • validateBean

      public <T> void validateBean(@NonNull @NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull @NonNull io.micronaut.inject.BeanDefinition<T> definition, @NonNull T bean) throws io.micronaut.context.exceptions.BeanInstantiationException
      Specified by:
      validateBean in interface io.micronaut.inject.validation.BeanDefinitionValidator
      Overrides:
      validateBean in class io.micronaut.validation.validator.DefaultValidator
      Throws:
      io.micronaut.context.exceptions.BeanInstantiationException