I have the following class that I'm trying to validate via Hibernate:
public class LoginForm
{
@NotBlank(message = "{myCustomMessage}")
private String user;
@NotBlank(message = "{myCustomMessage}")
private String pw;
//....
}
This works fine and my custom message is correctly displayed for NotBlank
, however if I have to specify the (message = "{myCustomMessage}")
line for every single constraint, for every single member, in every single class, its going to become very repetitive.
Is there a way to globally set this message, so it doesn't have to be specified individually for every member? I.e so it will, by default, fetch myCustomMessage
for @NotBlank
? (And for all the other constraints that I specify it for).
Edit: So if I rename the message key from myCustomMessage
to org.hibernate.validator.constraints.NotBlank.message
, then I no longer need to specify the (message..)
line. However, I'd still prefer if it could be made to work with myCustomMessage
globally.