I am trying to create a validator that is given the following method signature:
public void validateAllParameters(
final Method method,
final Object[] parameterValues)
If there is a violation, I would be throwing a ConstraintViolationException
I can iterate through parameterValues
and run .validate()
on each, but when I do that I do not have the path information that includes which parameter.
I tried to assemble parameterValues
into a map like this
Map<String, @Valid Object> parameterMap = new LinkedHashMap<>();
for (int i = 0; i < method.getParameterCount(); ++i) {
parameterMap.put(method.getParameters()[i].getName(), parameterValues[i]);
}
But
Set<ConstraintViolation<Object>> errors = validator.validate(parameterMap);
is an empty set i.e the validation didn't execute on the map.