Hello,
Everything works fine with my Hibernate (and javax) validation, except that the {value} is not replaced in messages.
Here is the way I do:
Code:
MessageInterpolator messageInterpolator = Validation.buildDefaultValidatorFactory().getMessageInterpolator();
LOG.debug("- messageTemplate: " + violation.getMessageTemplate());
LOG.debug("- constraintDescriptor: " + violation.getConstraintDescriptor());
LOG.debug("- invalidValue: " + violation.getInvalidValue());
LOG.debug("- message: " + messageInterpolator.interpolate(violation
.getMessageTemplate(), new Context() {
@Override
public ConstraintDescriptor<?> getConstraintDescriptor() {
return violation.getConstraintDescriptor();
}
@Override
public Object getValidatedValue() {
return violation.getInvalidValue();
}
}, locale));
Quote:
- messageTemplate: {org.hibernate.validator.constraints.Range.message}
- constraintDescriptor: ConstraintDescriptorImpl{annotation=org.hibernate.validator.constraints.Range, payloads=[], hasComposingConstraints=false, isReportAsSingleInvalidConstraint=true, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={message={org.hibernate.validator.constraints.Range.message}, min=0, payload=[Ljava.lang.Class;@965654, max=90, groups=[Ljava.lang.Class;@1fdd342}}
- invalidValue: 99
- message: {value} doit être entre 0 et 90
What is the problem with my code?
Thanks!