I am trying to add “custom” validation messages for the parameters called in a Controller method, per specific method (not in the global list of messages)
I found how to do that in a simple case, like:
@Required(message=”error.shouldspecifyname”) String username
I wonder if I can do a similar trick with validators having parameters.
So, I would like to convert
@Equals(“passwordRepeat”) String password
to something like
@Equals(“passwordRepeat”, message=”error.passwordsshouldmatch”)
What’s the correct syntax?
Thanks in advance.
As explained in the Javadocs,
@Equalsaccepts themessageparameter. Thus, you just need to write:(when you only specify one argument in an annotation, it means that you are defining the property
valueof this annotation)