Grails parameterized validation messages

In the messages.properties file in the Grails application, I saw examples of verification messages, for example:

User.password.size=Size of bar must be between {0} and {1} 

which applies to

 class User { String password static constraints = { password(size:5..15) } } 

This example assumes that {0} is tied to the minimum size, and {1} is tied to the maximum size, but I can not find any documentation about which parameters can be used by error messages for each built-in restriction. In other words, I would like to know: for each built-in constraint, the value is {0} .... {n}

+6
grails grails-validation
source share
2 answers

I did some experiments, and I found that for a limitation, such as:

 class User { String password static constraints = { password(size:5..15) } } 

Placeholder Values:

  0. Name of the class (User) 1. Name of the property (password) 2. Value of the property 3. First constraint parameter (5) 4. Second constraint parameter (15) 5. etc. 
+6
source share

You are right, I have not found any documentation. Best bet? Change your posts to something like:

 User.password.size=0:{0}, 1:{1}, 2:{2}, etc... 

and see what you get for every one that interests you. If you post this information on the Nabble bulletin board on Grails, I’m sure it will find it in the documentation.

Good luck.

0
source share

All Articles