That should be a simple problem but I couldn't find a straight forward solution.
I'm using the Spring Message Resource to provide all the texts on my system from a .properties file. I need that for internationalization questions and cannot use the default messages from the Spring.
Here is the problem:
I have the following line in my .properties file:
validator_invalid_state_name=Invalid name ({min}, {max})
The validation code is:
@Size( min=3, max=5, message="validator_invalid_state_name" )
public String name;
However, when an invalid value is sent to the field, the message is:
"Invalid name ({min}, {max})" and not "Invalid name (3, 5)".
I've tried several solutions without success, for example:
@Size( min=3, max=5, message="{validator_invalid_state_name}" )
@Size( min=3, max=5, message="${validator_invalid_state_name}" )
@Size( min=3, max=5, message="Size.name" ) // with "Size.name=Invalid name ({min}, {max})" in my .properties file
@Size( min=3, max=5, message="{Size.name}" ) //idem
But if I use only
@Size( min=3, max=5 )
Then, I get the default message from Spring (that I don't want to use). What I need is very simple: to use my own message from my custom .properties file, but using the parameters provided by the @Size annotation.
Any suggestions?
Thank you in advance.