Interface MethodValidationResult
- All Known Implementing Classes:
HandlerMethodValidationException
,MethodValidationException
public interface MethodValidationResult
Container for method validation results with validation errors from the
underlying library adapted to
MessageSourceResolvable
s and grouped
by method parameter as ParameterValidationResult
. For method parameters
with nested validation errors, the validation result is of type
ParameterErrors
and implements Errors
.- Since:
- 6.1
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodValidationResult
create
(Object target, Method method, List<ParameterValidationResult> results) Factory method to create aMethodValidationResult
instance.static MethodValidationResult
create
(Object target, Method method, List<ParameterValidationResult> results, List<MessageSourceResolvable> crossParameterErrors) Factory method to create aMethodValidationResult
instance.static MethodValidationResult
Factory method to create aMethodValidationResult
instance with 0 errors, suitable to use as a constant.default List<? extends MessageSourceResolvable>
Return a single list with all errors from all validation results.default List<ParameterValidationResult>
Deprecated, for removal: This API element is subject to removal in a future version.default List<ParameterErrors>
Return the subset ofallValidationResults
that includes Object method parameters with nested errors on their fields and properties.Return errors from cross-parameter validation.Return the method to which validation was applied.Return all validation results per method parameter, including bothgetValueResults()
andgetBeanResults()
.Return the target of the method invocation to which validation was applied.default List<ParameterValidationResult>
Return the subset ofallValidationResults
that includes method parameters with validation errors directly on method argument values.default boolean
Whether the result contains any validation errors.boolean
Whether the violations are for a return value.
-
Method Details
-
getTarget
Object getTarget()Return the target of the method invocation to which validation was applied. -
getMethod
Method getMethod()Return the method to which validation was applied. -
isForReturnValue
boolean isForReturnValue()Whether the violations are for a return value. If true the violations are from validating a return value. If false the violations are from validating method arguments. -
hasErrors
default boolean hasErrors()Whether the result contains any validation errors. -
getAllErrors
Return a single list with all errors from all validation results. -
getParameterValidationResults
List<ParameterValidationResult> getParameterValidationResults()Return all validation results per method parameter, including bothgetValueResults()
andgetBeanResults()
.Use
getCrossParameterValidationResults()
for access to errors from cross-parameter validation.- Since:
- 6.2
- See Also:
-
getAllValidationResults
@Deprecated(since="6.2", forRemoval=true) default List<ParameterValidationResult> getAllValidationResults()Deprecated, for removal: This API element is subject to removal in a future version.deprecated in favor ofgetParameterValidationResults()
Return all validation results. This includes both method parameters with errors directly on them, and Object method parameters with nested errors on their fields and properties.- See Also:
-
getValueResults
Return the subset ofallValidationResults
that includes method parameters with validation errors directly on method argument values. This excludesbeanResults
with nested errors on their fields and properties. -
getBeanResults
Return the subset ofallValidationResults
that includes Object method parameters with nested errors on their fields and properties. This excludesvalueResults
with validation errors directly on method arguments. -
getCrossParameterValidationResults
List<MessageSourceResolvable> getCrossParameterValidationResults()Return errors from cross-parameter validation.- Since:
- 6.2
-
create
static MethodValidationResult create(Object target, Method method, List<ParameterValidationResult> results) Factory method to create aMethodValidationResult
instance.- Parameters:
target
- the target Objectmethod
- the target methodresults
- method validation results, expected to be non-empty- Returns:
- the created instance
-
create
static MethodValidationResult create(Object target, Method method, List<ParameterValidationResult> results, List<MessageSourceResolvable> crossParameterErrors) Factory method to create aMethodValidationResult
instance.- Parameters:
target
- the target Objectmethod
- the target methodresults
- method validation results, expected to be non-emptycrossParameterErrors
- cross-parameter validation errors- Returns:
- the created instance
- Since:
- 6.2
-
emptyResult
Factory method to create aMethodValidationResult
instance with 0 errors, suitable to use as a constant. Getters for a target object or method are not supported.
-
getParameterValidationResults()