0

I'm trying to use a feature in bean-validation that I already used in the past, but I don't rembember how and i can't find any documentation.

import org.hibernate.validator.constraints.NotBlank;

public class User {

    protected String id;

    @NotBlank(message = "Name is mandatory for user {id}")
    protected String name;

    public String getId() {
        return id;
    }

}

In this example, {id} is not remplaced by instance id.

Is there any way to use any current bean property in message template ?

Regards.

chatellier
  • 179
  • 14

1 Answers1

1

You could use custom javax.validation.MessageInterpolator to achieve it.

Please see.. How do I dynamically resolve message parameters with Hibernate Validator?

Community
  • 1
  • 1
OTM
  • 656
  • 5
  • 8
  • This is not working. MessageInterpolator receive `String` (= name) in `context.getValidatedValue()` and not the `User` root instance. – chatellier Apr 03 '17 at 08:37