Search code examples
validationgrailsdomain-objectvalidationerror

Grails Validation Errors - Developer vs User


What is the best way to convert the developer-oriented validation error list you receive from calling validate() on a Grails domain object into user-oriented error messages?

Example:
Property [email] of class [class testproj.AuthUser] with value [x] is not a valid e-mail address

would rather have it read:
Email given is not a valid e-mail address

Is there anything built-in that already does this?


Solution

  • the messages.properties files in grails-app/i18n

    check out this documentation http://grails.org/doc/latest/guide/7.%20Validation.html

    To get all the error codes, look here http://grails.org/doc/latest/ref/Constraints/email.html. Enable the quick nav on the right. At the bottom of every constraint is the properties key that you use to change the error message.