Monday 12 November 2012

Grails weird size error message property convention

Alright, what I noticed about the grails domain validation errors, is that defined convention which suggests that; lets say

class MyDomain {
String field
    def constraint = {
    field size: 5..10
    }
}


normally, according to the grails convention property definition in the messages.properties file should be something like

mydomain.field.size=Field size must be 5 to 10 characters.


But instead the generated error code for the field is;

mydomain.field.size.error=Field size must be 5 to 10 characters.

I feel bothered about it because to understand that I have to check the error codes array. And what I notice that; grails (or spring I don't know I am a bit new to the spring framework and validation is part of the spring framework) generates about 20 different arbitrary error codes for the same error of the field? What is the logic behind it?