I am currently getting the following error message in a GSP page:
Property [namespace] of class [class com.domain.Tld] with value [partnerFebruary10BTESTTEST] does not fall within the valid size range from [0] to [20]
I would like to replace it with my own custom message.
I have added tried the following to messages.properties
:
com.domain.Tld.namespace.size.error.com.domain.Tld.namespace=The provided domain is too large and must not exceed {4} characters.
and
com.domain.Tld.namespace.size.toobig=The provided domain is too large and must not exceed {4} characters.
I have seen the other posts such as Grails Problem with custom error messages but I wasn't able to solve my problem.
Update
Domain constraints are:
static constraints = {
namespace size: 0..20, nullable: true, unique: "name"
}
I also found a class called Localization.groovy
with a method static String decodeMessage(String code, Locale locale)
. In the debugger the code default.invalid.size.message
is being used when this method is called.
Update2
I figured out that the specific project is using the localization plugin (https://github.com/halfbaked/grails-localizations) that basically loads the properties files into the databases. When a lookup for a code is made, the decodeMessage
method is called. The implementation of the specific decodeMessage
method was causing the nulls due to the implementation and hence the messages were never found.