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 
MessageSourceResolvables 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 SummaryModifier and TypeMethodDescriptionstatic MethodValidationResultcreate(Object target, Method method, List<ParameterValidationResult> results) Factory method to create aMethodValidationResultinstance.static MethodValidationResultcreate(Object target, Method method, List<ParameterValidationResult> results, List<MessageSourceResolvable> crossParameterErrors) Factory method to create aMethodValidationResultinstance.static MethodValidationResultFactory method to create aMethodValidationResultinstance 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 ofallValidationResultsthat 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 ofallValidationResultsthat includes method parameters with validation errors directly on method argument values.default booleanWhether the result contains any validation errors.booleanWhether the violations are for a return value.
- 
Method Details- 
getTargetObject getTarget()Return the target of the method invocation to which validation was applied.
- 
getMethodMethod getMethod()Return the method to which validation was applied.
- 
isForReturnValueboolean 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.
- 
hasErrorsdefault boolean hasErrors()Whether the result contains any validation errors.
- 
getAllErrorsReturn a single list with all errors from all validation results.
- 
getParameterValidationResultsList<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.As of Spring Framework 6.2, 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:
 
- 
getValueResultsReturn the subset ofallValidationResultsthat includes method parameters with validation errors directly on method argument values. This excludesbeanResultswith nested errors on their fields and properties.
- 
getBeanResultsReturn the subset ofallValidationResultsthat includes Object method parameters with nested errors on their fields and properties. This excludesvalueResultswith validation errors directly on method arguments.
- 
getCrossParameterValidationResultsList<MessageSourceResolvable> getCrossParameterValidationResults()Return errors from cross-parameter validation.- Since:
- 6.2
 
- 
createstatic MethodValidationResult create(Object target, Method method, List<ParameterValidationResult> results) Factory method to create aMethodValidationResultinstance.- Parameters:
- target- the target Object
- method- the target method
- results- method validation results, expected to be non-empty
- Returns:
- the created instance
 
- 
createstatic MethodValidationResult create(Object target, Method method, List<ParameterValidationResult> results, List<MessageSourceResolvable> crossParameterErrors) Factory method to create aMethodValidationResultinstance.- Parameters:
- target- the target Object
- method- the target method
- results- method validation results, expected to be non-empty
- crossParameterErrors- cross-parameter validation errors
- Returns:
- the created instance
- Since:
- 6.2
 
- 
emptyResultFactory method to create aMethodValidationResultinstance with 0 errors, suitable to use as a constant. Getters for a target object or method are not supported.
 
- 
getParameterValidationResults()