luke
luke

Reputation: 3599

Overriding default invalid email message in Grails

How can I override default message when email address isn't valid.
I have following constraints:

constraints = {
  ...
  email blank:false, email:true
}

I was trying to display message in the messages.properties with different combinations:

domainName.email.error
domainName.email.invalid
domainName.email.email

I'm able to display message when email is blank. Obviously I was trying to restart grails after modification, but it still doesn't works.

Thanks in advance for any help.

Upvotes: 0

Views: 1119

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122364

The correct message code to use for each constraint type can be found on the user guide page for the relevant constraint (choose the constraint you need from the right hand column). In the case of email it is

className.propertyName.email.invalid

so in your case

my.pkg.DomainClassName.email.email.invalid

(the first email being the property name and the second email being part of the email.invalid code).

Upvotes: 6

Related Questions