grailsgrails-ormgrails-validation

In Grails, I cannot override the default error message


class User {
     String userName
     static constraints = {
        userName nullable:false
     }
}

*** I tried the different combination of the following in the message.properties ***
User.userName.null.message=The User Name cannot be null/blank
User.userName.null=The User Name cannot be null/blank
[package].User.userName.null.message=The User Name cannot be null/blank 
[package].User.userName.null=The User Name cannot be null/blank 

But still no luck. I still receving the default error message which is "Property[userName] of clas[package_name] cannot be null. I'm using Grails 3.0.8


Solution

  • The key is user.userName.nullable. Use the following entry in your resource bundle.

    user.userName.nullable=Your custom text