Class DefaultConstraintValidatorContext<R>
java.lang.Object
io.micronaut.validation.validator.DefaultConstraintValidatorContext<R>
- Type Parameters:
R
- The root bean type
- All Implemented Interfaces:
ConstraintValidatorContext
,jakarta.validation.ConstraintValidatorContext
@Internal
public final class DefaultConstraintValidatorContext<R>
extends Object
implements ConstraintValidatorContext
The implementation of
ConstraintValidatorContext
.-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.validation.ConstraintValidatorContext
jakarta.validation.ConstraintValidatorContext.ConstraintViolationBuilder
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addViolation
(io.micronaut.validation.validator.DefaultConstraintViolation<R> violation) jakarta.validation.ConstraintValidatorContext.ConstraintViolationBuilder
buildConstraintViolationWithTemplate
(String messageTemplate) boolean
containsGroup
(Collection<Class<?>> constraintGroups) io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable
convertGroups
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) void
List<io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup>
List<io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup>
findGroupSequences
(io.micronaut.core.beans.BeanIntrospection<?> beanIntrospection) @NonNull jakarta.validation.ClockProvider
Returns the provider for obtaining the current time in the form of aClock
, e.g.io.micronaut.validation.validator.ValidationPath
Object[]
In case of using this constraint validator withjakarta.validation.ConstraintValidator
returns null, because JRS-303 doesn't support passing a root bean in their validation context.@NonNull BeanValidationContext
The validation context.boolean
boolean
isValidated
(Object obj) void
messageTemplate
(@Nullable String messageTemplate) Sets a message template to be used for the validation error message.<T> T
io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable
validating
(Object obj) io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable
withExecutableParameterValues
(Object[] executableParameterValues) io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable
withExecutableReturnValue
(Object executableReturnValue) io.micronaut.validation.validator.DefaultConstraintValidatorContext.GroupsValidation
withGroupSequence
(@NonNull io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup validationGroup)
-
Method Details
-
getValidationContext
The validation context.- Returns:
- The context
-
hasDefaultGroup
public boolean hasDefaultGroup() -
containsGroup
-
getExecutableParameterValues
-
getExecutableReturnValue
-
isValidated
-
validating
public io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable validating(Object obj) -
withExecutableParameterValues
public io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable withExecutableParameterValues(Object[] executableParameterValues) -
withExecutableReturnValue
public io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable withExecutableReturnValue(Object executableReturnValue) -
withGroupSequence
public io.micronaut.validation.validator.DefaultConstraintValidatorContext.GroupsValidation withGroupSequence(@NonNull @NonNull io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup validationGroup) -
convertGroups
public io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationCloseable convertGroups(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
findGroupSequences
public List<io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup> findGroupSequences(io.micronaut.core.beans.BeanIntrospection<?> beanIntrospection) -
findGroupSequences
public List<io.micronaut.validation.validator.DefaultConstraintValidatorContext.ValidationGroup> findGroupSequences() -
addViolation
-
getOverallViolations
-
getCurrentPath
public io.micronaut.validation.validator.ValidationPath getCurrentPath() -
getRootBean
Description copied from interface:ConstraintValidatorContext
In case of using this constraint validator withjakarta.validation.ConstraintValidator
returns null, because JRS-303 doesn't support passing a root bean in their validation context.- Specified by:
getRootBean
in interfaceConstraintValidatorContext
- Returns:
- The root bean under validation.
-
getRootClass
-
disableDefaultConstraintViolation
public void disableDefaultConstraintViolation()- Specified by:
disableDefaultConstraintViolation
in interfacejakarta.validation.ConstraintValidatorContext
-
getDefaultConstraintMessageTemplate
- Specified by:
getDefaultConstraintMessageTemplate
in interfacejakarta.validation.ConstraintValidatorContext
-
getClockProvider
@NonNull public @NonNull jakarta.validation.ClockProvider getClockProvider()Description copied from interface:ConstraintValidatorContext
Returns the provider for obtaining the current time in the form of aClock
, e.g. when validating theFuture
andPast
constraints.- Specified by:
getClockProvider
in interfaceConstraintValidatorContext
- Specified by:
getClockProvider
in interfacejakarta.validation.ConstraintValidatorContext
- Returns:
- the provider for obtaining the current time, never
null
. If no specific provider has been configured during bootstrap, a default implementation using the current system time and the current default time zone as returned byClock.systemDefaultZone()
will be returned.
-
buildConstraintViolationWithTemplate
public jakarta.validation.ConstraintValidatorContext.ConstraintViolationBuilder buildConstraintViolationWithTemplate(String messageTemplate) - Specified by:
buildConstraintViolationWithTemplate
in interfacejakarta.validation.ConstraintValidatorContext
-
unwrap
- Specified by:
unwrap
in interfacejakarta.validation.ConstraintValidatorContext
-
messageTemplate
Description copied from interface:ConstraintValidatorContext
Sets a message template to be used for the validation error message.- Specified by:
messageTemplate
in interfaceConstraintValidatorContext
- Parameters:
messageTemplate
- the message template
-