0

I want to know where Grails sets default error messages. For example I've got this one in my message.properties file. When I try to save data with wrong value, this message appears. But I can't understand where (in code) he sets this message.

default.invalid.min.message=Property {0} with value {2} is less than minimum value {3}
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
emilan
  • 12,825
  • 11
  • 32
  • 37

1 Answers1

2

Grails uses this message automatically when a property doesn't pass min constraint. You can override this message and edit your messages.properties file or you can create customised messages for your classes. Check out the documentation here: min constraint, the last sentence is Error Code: className.propertyName.min.notmet. So for a class Person and property age description for unmet min constraint your should use in your messages.properites:

person.age.min.notmet=Sorry, you're too young!
Tomasz Kalkosiński
  • 3,673
  • 1
  • 19
  • 25
  • Ok, I know that I can set custom error messages. My problem is another, I have 2 domain classes Form and FormItem, Form has many FormItem. I try to save Form with wrong FormItem values, and the result is duplicated error messages. Every error message printed twice. Now I want to understand where he sets these messages and why twice ? Other messages that are not connected with FormItem fields printed fine only one time. – emilan Apr 23 '12 at 13:20
  • 1
    @emilan maybe you're affected with this bug: http://jira.grails.org/browse/GRAILS-8924 ? – Tomasz Kalkosiński Apr 23 '12 at 13:53