MethodValidator that uses a Bean Validation
jakarta.validation.Validator for validation, and adapts
ConstraintViolations to MethodValidationResult.
| Modifier and Type | Class and Description |
|---|---|
| private static class | MethodValidationAdapter.
Default algorithm to select an object name, as described in
|
| public static interface | MethodValidationAdapter.
Strategy to resolve the name of an |
| private class | MethodValidationAdapter.
Builds a validation result for an |
| private class | MethodValidationAdapter.
Builds a validation result for a value method parameter with constraints declared directly on it. |
| private static class | MethodValidationAdapter.
Comparator for validation results, sorted by method parameter index first, also falling back on container indexes if necessary for cascaded constraints on a List container. |
| Modifier and Type | Field and Description |
|---|---|
| private static final MethodValidationAdapter. | |
| private static final MethodValidationResult | |
| private MessageCodesResolver | |
| private MethodValidationAdapter. | |
| private ParameterNameDiscoverer | |
| private static final Comparator | |
| private final Supplier | |
| private final Supplier |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MethodValidationAdapter(ValidatorFactory
the JSR-303 ValidatorFactory to use validatorFactory)Create an instance using the given JSR-303 ValidatorFactory. |
| public | MethodValidationAdapter(Validator
the JSR-303 Validator to use validator)Create an instance using the given JSR-303 Validator. |
| public | MethodValidationAdapter(Supplier<Validator>
a Supplier for the Validator to use validator)Create an instance for the supplied (potentially lazily initialized) Validator. |
| Modifier and Type | Method and Description |
|---|---|
| private MethodValidationResult | adaptViolations(Object target, Method method, Set<ConstraintViolation<Object>> violations, Function<Integer, MethodParameter> parameterFunction, Function<Integer, Object> argumentFunction)
|
| private BindingResult | |
| private MessageSourceResolvable | createMessageSourceResolvable(Object target, MethodParameter parameter, ConstraintViolation<Object> violation)
|
| public Class | determineValidationGroups(Object
the target Object target, Method the target method method)Implements org. Determine the applicable validation groups. |
| public MessageCodesResolver | |
| public ParameterNameDiscoverer | |
| public Supplier | |
| private MethodParameter | |
| private static Supplier | |
| public final Set | invokeValidatorForArguments(Object target, Method method, Object[] arguments, Class<?>[] groups)
Invoke the validator, and return the resulting violations. |
| public final Set | invokeValidatorForReturnValue(Object target, Method method, Object returnValue, Class<?>[] groups)
Invoke the validator, and return the resulting violations. |
| public void | setMessageCodesResolver(MessageCodesResolver messageCodesResolver)
Set the strategy to use to determine message codes for violations. |
| public void | setObjectNameResolver(MethodValidationAdapter.
Configure a resolver to determine the name of an |
| public void | setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the |
| public final MethodValidationResult | validateArguments(Object
the target Object target, Method the target method method, MethodParameter[] the parameters, if already created and available parameters, Object[] the candidate argument values to validate arguments, Class<?>[] validation groups from groups)determineValidationGroupsImplements org. Validate the given method arguments and return validation results. |
| public final MethodValidationResult | validateReturnValue(Object
the target Object target, Method the target method method, MethodParameter the return parameter, if already created and available returnType, Object the return value to validate returnValue, Class<?>[] validation groups from groups)determineValidationGroupsImplements org. Validate the given return value and return validation results. |
| defaultObjectNameResolver | back to summary |
|---|---|
| private static final MethodValidationAdapter. | |
| emptyValidationResult | back to summary |
|---|---|
| private static final MethodValidationResult emptyValidationResult | |
| messageCodesResolver | back to summary |
|---|---|
| private MessageCodesResolver messageCodesResolver | |
| objectNameResolver | back to summary |
|---|---|
| private MethodValidationAdapter. | |
| parameterNameDiscoverer | back to summary |
|---|---|
| private ParameterNameDiscoverer parameterNameDiscoverer | |
| resultComparator | back to summary |
|---|---|
| private static final Comparator<ParameterValidationResult> resultComparator | |
| validator | back to summary |
|---|---|
| private final Supplier<Validator> validator | |
| validatorAdapter | back to summary |
|---|---|
| private final Supplier<SpringValidatorAdapter> validatorAdapter | |
| MethodValidationAdapter | back to summary |
|---|---|
| public MethodValidationAdapter() Create an instance using a default JSR-303 validator underneath. | |
| MethodValidationAdapter | back to summary |
|---|---|
| public MethodValidationAdapter(ValidatorFactory validatorFactory) Create an instance using the given JSR-303 ValidatorFactory.
| |
| MethodValidationAdapter | back to summary |
|---|---|
| public MethodValidationAdapter(Validator validator) Create an instance using the given JSR-303 Validator.
| |
| MethodValidationAdapter | back to summary |
|---|---|
| public MethodValidationAdapter(Supplier<Validator> validator) Create an instance for the supplied (potentially lazily initialized) Validator. | |
| adaptViolations | back to summary |
|---|---|
| private MethodValidationResult adaptViolations(Object target, Method method, Set<ConstraintViolation<Object>> violations, Function<Integer, MethodParameter> parameterFunction, Function<Integer, Object> argumentFunction) | |
| createBindingResult | back to summary |
|---|---|
| private BindingResult createBindingResult(MethodParameter parameter, Object argument) | |
| createMessageSourceResolvable | back to summary |
|---|---|
| private MessageSourceResolvable createMessageSourceResolvable(Object target, MethodParameter parameter, ConstraintViolation<Object> violation) | |
| determineValidationGroups | back to summary |
|---|---|
| public Class Implements org. Doc from org. Determine the applicable validation groups. By default, obtained from an
Default are the validation groups as specified in the | |
| getMessageCodesResolver | back to summary |
|---|---|
| public MessageCodesResolver getMessageCodesResolver() Return the | |
| getParameterNameDiscoverer | back to summary |
|---|---|
| public ParameterNameDiscoverer getParameterNameDiscoverer() Return the | |
| getSpringValidatorAdapter | back to summary |
|---|---|
| public Supplier Return the | |
| initMethodParameter | back to summary |
|---|---|
| private MethodParameter initMethodParameter(Method method, int index) | |
| initValidatorAdapter | back to summary |
|---|---|
| private static Supplier | |
| invokeValidatorForArguments | back to summary |
|---|---|
| public final Set Invoke the validator, and return the resulting violations. | |
| invokeValidatorForReturnValue | back to summary |
|---|---|
| public final Set Invoke the validator, and return the resulting violations. | |
| setMessageCodesResolver | back to summary |
|---|---|
| public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) Set the strategy to use to determine message codes for violations. Default is a DefaultMessageCodesResolver. | |
| setObjectNameResolver | back to summary |
|---|---|
| public void setObjectNameResolver(MethodValidationAdapter. Configure a resolver to determine the name of an By default, the object name is resolved through:
| |
| setParameterNameDiscoverer | back to summary |
|---|---|
| public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) Set the Default is | |
| validateArguments | back to summary |
|---|---|
| public final MethodValidationResult validateArguments(Object target, Method method, MethodParameter[] parameters, Object[] arguments, Class<?>[] groups) Implements org. Doc from org. Validate the given method arguments and return validation results.
| |
| validateReturnValue | back to summary |
|---|---|
| public final MethodValidationResult validateReturnValue(Object target, Method method, MethodParameter returnType, Object returnValue, Class<?>[] groups) Implements org. Doc from org. Validate the given return value and return validation results.
| |
setObjectNameResolver(ObjectNameResolver).
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | resolveName(MethodParameter
the method parameter parameter, Object the argument value or return value value)Implements org. Determine the name for the given method argument. |
| DefaultObjectNameResolver | back to summary |
|---|---|
| private DefaultObjectNameResolver() | |
| resolveName | back to summary |
|---|---|
| public String resolveName(MethodParameter parameter, Object value) Implements org. Doc from org. Determine the name for the given method argument.
| |
@Valid method parameter to
use for its BindingResult.
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: the name to usethe method parameter parameter, Object the argument value or return value value)Determine the name for the given method argument. |
| resolveName | back to summary |
|---|---|
| public String resolveName(MethodParameter parameter, Object value) Determine the name for the given method argument.
| |
@Valid
annotated bean method parameter with cascaded constraints.
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final Object | |
| private final Integer | |
| private final Object | |
| private final Errors | |
| private final MethodParameter | |
| private final Set |
| Access | Constructor and Description |
|---|---|
| public | ParamErrorsBuilder(MethodParameter param, Object bean, Object container, Integer containerIndex, Object containerKey)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ParameterErrors |
| bean | back to summary |
|---|---|
| private final Object bean
| |
| container | back to summary |
|---|---|
| private final Object container
| |
| containerIndex | back to summary |
|---|---|
| private final Integer containerIndex
| |
| containerKey | back to summary |
|---|---|
| private final Object containerKey
| |
| errors | back to summary |
|---|---|
| private final Errors errors | |
| parameter | back to summary |
|---|---|
| private final MethodParameter parameter | |
| violations | back to summary |
|---|---|
| private final Set<ConstraintViolation<Object>> violations | |
| ParamErrorsBuilder | back to summary |
|---|---|
| public ParamErrorsBuilder(MethodParameter param, Object bean, Object container, Integer containerIndex, Object containerKey) | |
| addViolation | back to summary |
|---|---|
| public void addViolation(ConstraintViolation<Object> violation) | |
| build | back to summary |
|---|---|
| public ParameterErrors build() | |
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final Integer | |
| private final Object | |
| private final MethodParameter | |
| private final List | |
| private final Object | |
| private final Object |
| Access | Constructor and Description |
|---|---|
| public | ParamValidationResultBuilder(Object target, MethodParameter parameter, Object value, Object container, Integer containerIndex, Object containerKey)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ParameterValidationResult |
| container | back to summary |
|---|---|
| private final Object container
| |
| containerIndex | back to summary |
|---|---|
| private final Integer containerIndex
| |
| containerKey | back to summary |
|---|---|
| private final Object containerKey
| |
| parameter | back to summary |
|---|---|
| private final MethodParameter parameter | |
| resolvableErrors | back to summary |
|---|---|
| private final List<MessageSourceResolvable> resolvableErrors | |
| target | back to summary |
|---|---|
| private final Object target | |
| value | back to summary |
|---|---|
| private final Object value
| |
| ParamValidationResultBuilder | back to summary |
|---|---|
| public ParamValidationResultBuilder(Object target, MethodParameter parameter, Object value, Object container, Integer containerIndex, Object containerKey) | |
| addViolation | back to summary |
|---|---|
| public void addViolation(ConstraintViolation<Object> violation) | |
| build | back to summary |
|---|---|
| public ParameterValidationResult build() | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(ParameterValidationResult
the first object to be compared. result1, ParameterValidationResult the second object to be compared. result2)Implements java. Compares its two arguments for order. |
| private <E> int |
| ResultComparator | back to summary |
|---|---|
| private ResultComparator() | |
| compare | back to summary |
|---|---|
| public int compare(ParameterValidationResult result1, ParameterValidationResult result2) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| compareKeys | back to summary |
|---|---|
private <E> int compareKeys(ParameterErrors errors1, ParameterErrors errors2)
| |