added MethodValidationInterceptor/PostProcessor for Hibernate Validator 4.2 based method validation; renamed Spring's variant of @Valid to @Validated
This commit is contained in:
@@ -295,7 +295,7 @@ public class HandlerMethodInvoker {
|
||||
else if (Value.class.isInstance(paramAnn)) {
|
||||
defaultValue = ((Value) paramAnn).value();
|
||||
}
|
||||
else if ("Valid".equals(paramAnn.annotationType().getSimpleName())) {
|
||||
else if (paramAnn.annotationType().getSimpleName().startsWith("Valid")) {
|
||||
validate = true;
|
||||
Object value = AnnotationUtils.getValue(paramAnn);
|
||||
validationHints = (value instanceof Object[] ? (Object[]) value : new Object[] {value});
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol
|
||||
protected void validateIfApplicable(WebDataBinder binder, MethodParameter parameter) {
|
||||
Annotation[] annotations = parameter.getParameterAnnotations();
|
||||
for (Annotation annot : annotations) {
|
||||
if ("Valid".equals(annot.annotationType().getSimpleName())) {
|
||||
if (annot.annotationType().getSimpleName().startsWith("Valid")) {
|
||||
Object hints = AnnotationUtils.getValue(annot);
|
||||
binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user