Support cross-parameter validation
Closes gh-33271
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -107,8 +108,13 @@ public class HandlerMethodValidationException extends ResponseStatusException im
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ParameterValidationResult> getAllValidationResults() {
|
||||
return this.validationResult.getAllValidationResults();
|
||||
public List<ParameterValidationResult> getParameterValidationResults() {
|
||||
return this.validationResult.getParameterValidationResults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageSourceResolvable> getCrossParameterValidationResults() {
|
||||
return this.validationResult.getCrossParameterValidationResults();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +122,7 @@ public class HandlerMethodValidationException extends ResponseStatusException im
|
||||
* through callback methods organized by controller method parameter type.
|
||||
*/
|
||||
public void visitResults(Visitor visitor) {
|
||||
for (ParameterValidationResult result : getAllValidationResults()) {
|
||||
for (ParameterValidationResult result : getParameterValidationResults()) {
|
||||
MethodParameter param = result.getMethodParameter();
|
||||
CookieValue cookieValue = param.getParameterAnnotation(CookieValue.class);
|
||||
if (cookieValue != null) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class HandlerMethodValidator implements MethodValidator {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.getAllValidationResults().size() == bindingResultCount) {
|
||||
if (result.getParameterValidationResults().size() == bindingResultCount) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user