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 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:
    • 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

      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.
    • 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
    • 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.