@Singleton @Primary @Requires(property="micronaut.validator.enabled", value="true", defaultValue="true") public class DefaultValidator extends Object implements Validator, ExecutableMethodValidator, ReactiveValidator, AnnotatedElementValidator
Validator interface.| Modifier | Constructor and Description |
|---|---|
protected |
DefaultValidator(ValidatorConfiguration configuration)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
createValid(Class<T> beanType,
Object... arguments)
Create a new valid instance.
|
ExecutableMethodValidator |
forExecutables()
Overridden variation that returns a
ExecutableMethodValidator. |
protected BeanIntrospection<Object> |
getBeanIntrospection(Object object)
looks up a bean introspection for the given object.
|
protected BeanIntrospection<Object> |
getBeanIntrospection(Object object,
Class<?> definedClass)
looks up a bean introspection for the given object by instance's class or defined class.
|
BeanDescriptor |
getConstraintsForClass(Class<?> clazz) |
<T> T |
unwrap(Class<T> type) |
<T> Set<ConstraintViolation<T>> |
validate(BeanIntrospection<T> introspection,
T object,
Class<?>... groups)
Validate the given introspection and object.
|
<T> Set<ConstraintViolation<T>> |
validate(T object,
Class<?>... groups) |
<T> CompletionStage<T> |
validateCompletionStage(CompletionStage<T> completionStage,
Class<?>... groups)
Validate the given CompletionStage by returning a new CompletionStage that validates the emitted value.
|
<T> Set<ConstraintViolation<T>> |
validateConstructorParameters(BeanIntrospection<? extends T> introspection,
Object[] parameterValues,
Class<?>... groups)
Validates parameters for the given introspection and values.
|
<T> Set<ConstraintViolation<T>> |
validateConstructorParameters(Constructor<? extends T> constructor,
Object[] parameterValues,
Class<?>... groups) |
<T> Set<ConstraintViolation<T>> |
validateConstructorReturnValue(Constructor<? extends T> constructor,
T createdObject,
Class<?>... groups) |
Set<String> |
validatedAnnotatedElement(AnnotatedElement element,
Object value)
Validates an annotated element for the given value.
|
<T> Set<ConstraintViolation<T>> |
validateParameters(T object,
ExecutableMethod method,
Collection<MutableArgumentValue<?>> argumentValues,
Class<?>... groups)
Validate the parameter values of the given
ExecutableMethod. |
<T> Set<ConstraintViolation<T>> |
validateParameters(T object,
ExecutableMethod method,
Object[] parameterValues,
Class<?>... groups)
Validate the parameter values of the given
ExecutableMethod. |
<T> Set<ConstraintViolation<T>> |
validateParameters(T object,
Method method,
Object[] parameterValues,
Class<?>... groups) |
<T> Set<ConstraintViolation<T>> |
validateProperty(T object,
String propertyName,
Class<?>... groups) |
<T> Publisher<T> |
validatePublisher(Publisher<T> publisher,
Class<?>... groups)
Validate the given publisher by returning a new Publisher that validates each emitted value.
|
<T> Set<ConstraintViolation<T>> |
validateReturnValue(T object,
ExecutableMethod<?,Object> executableMethod,
Object returnValue,
Class<?>... groups)
Validates the return value of a
ExecutableMethod. |
<T> Set<ConstraintViolation<T>> |
validateReturnValue(T object,
Method method,
Object returnValue,
Class<?>... groups) |
<T> Set<ConstraintViolation<T>> |
validateValue(Class<T> beanType,
String propertyName,
Object value,
Class<?>... groups) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstance@Inject protected DefaultValidator(@Nonnull ValidatorConfiguration configuration)
configuration - The validator configuration@Nonnull public <T> Set<ConstraintViolation<T>> validate(@Nonnull T object, @Nullable Class<?>... groups)
@Nonnull public <T> Set<ConstraintViolation<T>> validate(@Nonnull BeanIntrospection<T> introspection, @Nonnull T object, @Nullable Class<?>... groups)
T - The object typeintrospection - The introspectionobject - The objectgroups - The groups@Nonnull public <T> Set<ConstraintViolation<T>> validateProperty(@Nonnull T object, @Nonnull String propertyName, @Nullable Class<?>... groups)
validateProperty in interface Validator@Nonnull public <T> Set<ConstraintViolation<T>> validateValue(@Nonnull Class<T> beanType, @Nonnull String propertyName, @Nullable Object value, @Nullable Class<?>... groups)
validateValue in interface Validator@Nonnull public Set<String> validatedAnnotatedElement(@Nonnull AnnotatedElement element, @Nullable Object value)
AnnotatedElementValidatorvalidatedAnnotatedElement in interface AnnotatedElementValidatorelement - The elementvalue - The value@Nonnull public <T> T createValid(@Nonnull Class<T> beanType, Object... arguments) throws ConstraintViolationException
ExecutableMethodValidatorcreateValid in interface ExecutableMethodValidatorT - the generic typebeanType - The typearguments - The argumentsConstraintViolationException - If a valid instance couldn't be constructedpublic BeanDescriptor getConstraintsForClass(Class<?> clazz)
getConstraintsForClass in interface Validator@Nonnull public ExecutableMethodValidator forExecutables()
ValidatorExecutableMethodValidator.forExecutables in interface Validator@Nonnull public <T> Set<ConstraintViolation<T>> validateParameters(@Nonnull T object, @Nonnull ExecutableMethod method, @Nonnull Object[] parameterValues, @Nullable Class<?>... groups)
ExecutableMethodValidatorExecutableMethod.validateParameters in interface ExecutableMethodValidatorT - The object typeobject - The objectmethod - The methodparameterValues - The valuesgroups - The groups@Nonnull public <T> Set<ConstraintViolation<T>> validateParameters(@Nonnull T object, @Nonnull ExecutableMethod method, @Nonnull Collection<MutableArgumentValue<?>> argumentValues, @Nullable Class<?>... groups)
ExecutableMethodValidatorExecutableMethod.validateParameters in interface ExecutableMethodValidatorT - The object typeobject - The objectmethod - The methodargumentValues - The valuesgroups - The groups@Nonnull public <T> Set<ConstraintViolation<T>> validateParameters(@Nonnull T object, @Nonnull Method method, @Nonnull Object[] parameterValues, @Nullable Class<?>... groups)
validateParameters in interface ExecutableMethodValidatorvalidateParameters in interface javax.validation.executable.ExecutableValidator@Nonnull public <T> Set<ConstraintViolation<T>> validateReturnValue(@Nonnull T object, @Nonnull Method method, @Nullable Object returnValue, @Nullable Class<?>... groups)
validateReturnValue in interface ExecutableMethodValidatorvalidateReturnValue in interface javax.validation.executable.ExecutableValidator@Nonnull public <T> Set<ConstraintViolation<T>> validateReturnValue(@Nonnull T object, @Nonnull ExecutableMethod<?,Object> executableMethod, @Nullable Object returnValue, @Nullable Class<?>... groups)
ExecutableMethodValidatorExecutableMethod.validateReturnValue in interface ExecutableMethodValidatorT - The object typeobject - The objectexecutableMethod - The methodreturnValue - The return valuegroups - The groups@Nonnull public <T> Set<ConstraintViolation<T>> validateConstructorParameters(@Nonnull Constructor<? extends T> constructor, @Nonnull Object[] parameterValues, @Nullable Class<?>... groups)
validateConstructorParameters in interface ExecutableMethodValidatorvalidateConstructorParameters in interface javax.validation.executable.ExecutableValidator@Nonnull public <T> Set<ConstraintViolation<T>> validateConstructorParameters(@Nonnull BeanIntrospection<? extends T> introspection, @Nonnull Object[] parameterValues, @Nullable Class<?>... groups)
ExecutableMethodValidatorvalidateConstructorParameters in interface ExecutableMethodValidatorT - The bean type.introspection - The introspectionparameterValues - The parameter valuesgroups - The groups@Nonnull public <T> Set<ConstraintViolation<T>> validateConstructorReturnValue(@Nonnull Constructor<? extends T> constructor, @Nonnull T createdObject, @Nullable Class<?>... groups)
validateConstructorReturnValue in interface ExecutableMethodValidatorvalidateConstructorReturnValue in interface javax.validation.executable.ExecutableValidator@Nullable protected BeanIntrospection<Object> getBeanIntrospection(@Nonnull Object object, @Nonnull Class<?> definedClass)
object - The object, never nulldefinedClass - The defined class of the object, never null@Nullable protected BeanIntrospection<Object> getBeanIntrospection(@Nonnull Object object)
object - The object, never null@Nonnull public <T> Publisher<T> validatePublisher(@Nonnull Publisher<T> publisher, Class<?>... groups)
ReactiveValidatorConstraintViolationException will be thrown.validatePublisher in interface ReactiveValidatorT - The generic typepublisher - The publishergroups - The groups@Nonnull public <T> CompletionStage<T> validateCompletionStage(@Nonnull CompletionStage<T> completionStage, Class<?>... groups)
ReactiveValidatorConstraintViolationException will be thrown.validateCompletionStage in interface ReactiveValidatorT - The generic typecompletionStage - The completion stagegroups - The groups