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
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.Return all validation results.default List<ParameterErrors>
Return the subset ofallValidationResults
that includes Object method parameters with nested errors on their fields and properties.Return the method to which validation was applied.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. -
getAllValidationResults
List<ParameterValidationResult> getAllValidationResults()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. -
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
-
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.
-