Spring validation annotation using message with parameters

1.1k views Asked by At

I'm trying to use annotations with a custom message in spring/hibernate validation. What I want to do is support internationalization while being able to pass in a parameter.

For instance, here is the field in the java class:

@NotEmpty (message = "{error.required}")
public String name;

ValidationMessages.properties has this:

error.required = {0} is a required field

So I'm looking for a way to pass in the field name into that message using the message annotation in the java class. Is this even possible?

EDIT: Similar you this question: JSR 303 Bean Validation in Spring

0

There are 0 answers