Currently, I have something like
@NotNull(message="{err.required}")
@Size(min=1, message="{err.required}")
private String firstName;
In my messages.properties
, I have
err.required={0} is required.
It works but it prints out firstName is required.
which is ugly. It passed the variable name firstName
as parameter in {0}
.
How do I pass in something like "First name" instead? So it will become First name is required.
You could do something like this:
and in properties file
or if you want to be more clear, you could add your own annotation and validator:
Then your field
And in properties (although it's not mandatory since you can default the value to this):