SpringValidatorAdapter properly handles HV-5-style list constraint violations

Issue: SPR-15082
This commit is contained in:
Juergen Hoeller
2017-01-12 21:16:56 +01:00
parent b06423a5f8
commit d0e93284f3
2 changed files with 70 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -255,7 +255,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
protected Object getRejectedValue(String field, ConstraintViolation<Object> violation, BindingResult bindingResult) {
Object invalidValue = violation.getInvalidValue();
if (!"".equals(field) && (invalidValue == violation.getLeafBean() ||
(field.contains(".") && !field.contains("[]")))) {
(!field.contains("[]") && (field.contains("[") || field.contains("."))))) {
// Possibly a bean constraint with property path: retrieve the actual property value.
// However, explicitly avoid this for "address[]" style paths that we can't handle.
invalidValue = bindingResult.getRawFieldValue(field);