Class DefaultConstraintValidators

java.lang.Object
io.micronaut.validation.validator.constraints.DefaultConstraintValidators
All Implemented Interfaces:
ConstraintValidatorRegistry

@Singleton @Introspected public class DefaultConstraintValidators extends Object implements ConstraintValidatorRegistry
A factory bean that contains implementation for many of the default validations. This approach is preferred as it generates fewer classes and smaller byte code than defining a validator class for each case.
Since:
1.2
Author:
graemerocher
  • Constructor Details

    • DefaultConstraintValidators

      public DefaultConstraintValidators()
      Default constructor.
    • DefaultConstraintValidators

      @Inject public DefaultConstraintValidators(@Nullable @Nullable io.micronaut.context.BeanContext beanContext)
      Constructor used for DI.
      Parameters:
      beanContext - The bean context
  • Method Details

    • findConstraintValidator

      @NonNull public <A extends Annotation, T> @NonNull Optional<ConstraintValidator<A,T>> findConstraintValidator(@NonNull @NonNull Class<A> constraintType, @NonNull @NonNull Class<T> targetType)
      Description copied from interface: ConstraintValidatorRegistry
      Finds a constraint validator for the given type and target type.
      Specified by:
      findConstraintValidator in interface ConstraintValidatorRegistry
      Type Parameters:
      A - The annotation type
      T - The target type
      Parameters:
      constraintType - The annotation type of the constraint.
      targetType - The type being validated.
      Returns:
      The validator
    • findLocalConstraintValidator

      protected <A extends Annotation, T> Optional<ConstraintValidator<A,T>> findLocalConstraintValidator(@NonNull @NonNull Class<A> constraintType, @NonNull @NonNull Class<T> targetType)
      Last chance resolve for constraint validator.
      Type Parameters:
      A - The annotation type
      T - The target type
      Parameters:
      constraintType - The constraint type
      targetType - The target type
      Returns:
      The validator if present