Top Description Methods
org.springframework.validation.method

public Interface MethodValidationResult

Known Direct Implementers
org.springframework.validation.method.DefaultMethodValidationResult, org.springframework.validation.method.EmptyMethodValidationResult, org.springframework.validation.method.MethodValidationException
Imports
java.lang.reflect.Method, java.util.List, org.springframework.context.MessageSourceResolvable, org.springframework.validation.Errors

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.
Author
Rossen Stoyanchev
Since
6.1

Method Summary

Modifier and TypeMethod and Description
public static MethodValidationResult

Returns:

the created instance
create
(Object
the target Object
target
,
Method
the target method
method
,
List<ParameterValidationResult>
method validation results, expected to be non-empty
results
)

Factory method to create a MethodValidationResult instance.

public static MethodValidationResult
emptyResult()

Factory method to create a MethodValidationResult instance with 0 errors, suitable to use as a constant.

public default List<? extends MessageSourceResolvable>
getAllErrors()

Return a single list with all errors from all validation results.

public List<ParameterValidationResult>
getAllValidationResults()

Return all validation results.

public default List<ParameterErrors>
getBeanResults()

Return the subset of allValidationResults that includes Object method parameters with nested errors on their fields and properties.

public Method
getMethod()

Return the method to which validation was applied.

public Object
getTarget()

Return the target of the method invocation to which validation was applied.

public default List<ParameterValidationResult>
getValueResults()

Return the subset of allValidationResults that includes method parameters with validation errors directly on method argument values.

public default boolean
hasErrors()

Whether the result contains any validation errors.

public boolean
isForReturnValue()

Whether the violations are for a return value.

Method Detail

createback to summary
public static MethodValidationResult create(Object target, Method method, List<ParameterValidationResult> results)

Factory method to create a MethodValidationResult instance.

Parameters
target:Object

the target Object

method:Method

the target method

results:List<ParameterValidationResult>

method validation results, expected to be non-empty

Returns:MethodValidationResult

the created instance

emptyResultback to summary
public 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.

getAllErrorsback to summary
public default List<? extends MessageSourceResolvable> getAllErrors()

Return a single list with all errors from all validation results.

See Also
getAllValidationResults(), ParameterValidationResult#getResolvableErrors()
getAllValidationResultsback to summary
public 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(), getBeanResults()
getBeanResultsback to summary
public 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.

getMethodback to summary
public Method getMethod()

Return the method to which validation was applied.

getTargetback to summary
public Object getTarget()

Return the target of the method invocation to which validation was applied.

getValueResultsback to summary
public 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.

hasErrorsback to summary
public default boolean hasErrors()

Whether the result contains any validation errors.

isForReturnValueback to summary
public 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.