Package org.springframework.validation.method

# Interface MethodValidationResult

All Known Implementing Classes:
  `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 Type
Method
Description
`static MethodValidationResult`
`create(Object target, Method method, List<ParameterValidationResult> results)`
Factory method to create a `MethodValidationResult` instance.
`static MethodValidationResult`
`create(Object target, Method method, List<ParameterValidationResult> results, List<MessageSourceResolvable> crossParameterErrors)`
Factory method to create a `MethodValidationResult` instance.
`static MethodValidationResult`
`emptyResult()`
Factory method to create a `MethodValidationResult` instance with 0 errors, suitable to use as a constant.
`default List<? extends MessageSourceResolvable>`
`getAllErrors()`
Return a single list with all errors from all validation results.
`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 of `getParameterValidationResults()`
`default List<ParameterErrors>`
`getBeanResults()`
Return the subset of `allValidationResults` that includes Object method parameters with nested errors on their fields and properties.
`List<MessageSourceResolvable>`
`getCrossParameterValidationResults()`
Return errors from cross-parameter validation.
`Method`
`getMethod()`
Return the method to which validation was applied.
`List<ParameterValidationResult>`
`getParameterValidationResults()`
Return all validation results per method parameter, including both `getValueResults()` and `getBeanResults()`.
`Object`
`getTarget()`
Return the target of the method invocation to which validation was applied.
`default List<ParameterValidationResult>`
`getValueResults()`
Return the subset of `allValidationResults` that includes method parameters with validation errors directly on method argument values.
`default boolean`
`hasErrors()`
Whether the result contains any validation errors.
`boolean`
`isForReturnValue()`
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

default List<? extends MessageSourceResolvable> getAllErrors()
Return a single list with all errors from all validation results.

See Also:
  - `getParameterValidationResults()`
  - `ParameterValidationResult.getResolvableErrors()`

### getParameterValidationResults

List<ParameterValidationResult> getParameterValidationResults()
Return all validation results per method parameter, including both `getValueResults()` and `getBeanResults()`.

Use `getCrossParameterValidationResults()` for access to errors from cross-parameter validation.

Since:
  6.2
See Also:
  - `getValueResults()`
  - `getBeanResults()`

### 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 of `getParameterValidationResults()`
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()`
  - `getBeanResults()`

### getValueResults

default List<ParameterValidationResult> getValueResults()
Return the subset of `allValidationResults` that includes method parameters with validation errors directly on method argument values. This excludes `beanResults` with nested errors on their fields and properties.

### getBeanResults

default List<ParameterErrors> getBeanResults()
Return the subset of `allValidationResults` that includes Object method parameters with nested errors on their fields and properties. This excludes `valueResults` 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 a `MethodValidationResult` instance.

Parameters:
  `target` - the target Object
  `method` - the target method
  `results` - 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 a `MethodValidationResult` instance.

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

### emptyResult

static MethodValidationResult emptyResult()
Factory method to create a `MethodValidationResult` instance with 0 errors, suitable to use as a constant. Getters for a target object or method are not supported.