@@ -230,7 +230,8 @@ public MethodValidationResult validateMethodArguments(
230
230
Method bridgedMethod = BridgeMethodResolver .findBridgedMethod (mostSpecificMethod );
231
231
result = execVal .validateParameters (target , bridgedMethod , arguments , groups );
232
232
}
233
- return (result .isEmpty () ? EMPTY_RESULT : createException (target , method , result , i -> arguments [i ]));
233
+ return (result .isEmpty () ? EMPTY_RESULT :
234
+ createException (target , method , result , i -> arguments [i ], false ));
234
235
}
235
236
236
237
/**
@@ -249,12 +250,12 @@ public MethodValidationResult validateMethodReturnValue(
249
250
250
251
ExecutableValidator execVal = this .validator .get ().forExecutables ();
251
252
Set <ConstraintViolation <Object >> result = execVal .validateReturnValue (target , method , returnValue , groups );
252
- return (result .isEmpty () ? EMPTY_RESULT : createException (target , method , result , i -> returnValue ));
253
+ return (result .isEmpty () ? EMPTY_RESULT : createException (target , method , result , i -> returnValue , true ));
253
254
}
254
255
255
256
private MethodValidationException createException (
256
257
Object target , Method method , Set <ConstraintViolation <Object >> violations ,
257
- Function <Integer , Object > argumentFunction ) {
258
+ Function <Integer , Object > argumentFunction , boolean forReturnValue ) {
258
259
259
260
Map <MethodParameter , ValueResultBuilder > parameterViolations = new LinkedHashMap <>();
260
261
Map <Path .Node , BeanResultBuilder > cascadedViolations = new LinkedHashMap <>();
@@ -296,7 +297,7 @@ else if (node.getKind().equals(ElementKind.RETURN_VALUE)) {
296
297
cascadedViolations .forEach ((node , builder ) -> validatonResultList .add (builder .build ()));
297
298
validatonResultList .sort (RESULT_COMPARATOR );
298
299
299
- return new MethodValidationException (target , method , violations , validatonResultList );
300
+ return new MethodValidationException (target , method , violations , validatonResultList , forReturnValue );
300
301
}
301
302
302
303
/**
@@ -549,6 +550,11 @@ public List<ParameterErrors> getBeanResults() {
549
550
public void throwIfViolationsPresent () {
550
551
}
551
552
553
+ @ Override
554
+ public String toString () {
555
+ return "MethodValidationResult (0 violations)" ;
556
+ }
557
+
552
558
}
553
559
554
560
}
0 commit comments