Search in sources :

Example 1 with BeanDefinitionValidator

use of io.micronaut.inject.validation.BeanDefinitionValidator in project micronaut-core by micronaut-projects.

the class ValidatedBeanDefinition method validate.

/**
 * Validates the bean with the validator factory if present.
 *
 * @param resolutionContext The resolution context
 * @param instance          The instance
 * @return The instance
 */
default T validate(BeanResolutionContext resolutionContext, T instance) {
    BeanDefinitionValidator validator = resolutionContext.getContext().getBeanValidator();
    validator.validateBean(resolutionContext, this, instance);
    return instance;
}
Also used : BeanDefinitionValidator(io.micronaut.inject.validation.BeanDefinitionValidator)

Example 2 with BeanDefinitionValidator

use of io.micronaut.inject.validation.BeanDefinitionValidator in project micronaut-core by micronaut-projects.

the class ValidatedBeanDefinition method validateBeanArgument.

/**
 * Validates the given bean after it has been constructor.
 *
 * @param resolutionContext The resolution context
 * @param injectionPoint    The injection point
 * @param argument          The argument
 * @param index             The argument index
 * @param value             The value
 * @param <V>               The value type
 * @throws BeanInstantiationException if the bean is invalid
 */
default <V> void validateBeanArgument(@NonNull BeanResolutionContext resolutionContext, @NonNull InjectionPoint injectionPoint, @NonNull Argument<V> argument, int index, @Nullable V value) throws BeanInstantiationException {
    BeanDefinitionValidator validator = resolutionContext.getContext().getBeanValidator();
    validator.validateBeanArgument(resolutionContext, injectionPoint, argument, index, value);
}
Also used : BeanDefinitionValidator(io.micronaut.inject.validation.BeanDefinitionValidator)

Aggregations

BeanDefinitionValidator (io.micronaut.inject.validation.BeanDefinitionValidator)2