grails-constraints icon indicating copy to clipboard operation
grails-constraints copied to clipboard

Docs for defaultMessageCode give incorrect message code name

Open jonroler opened this issue 11 years ago • 0 comments

The docs here:

https://github.com/geofflane/grails-constraints/blob/master/README.markdown#defaultmessagecode-property-optional

state that "The default value is default.$name.invalid.message". However, it appears that the actual default value of the defaultMessageCode is default.invalid.$name.message ($name and invalid are in different orders). However, I don't think the fix should be to change the docs. To be consistent with the rest of grails (look at the default messages for the built-in grails constraints as well as the message codes defined for custom constraints by this plugin), I believe the code should be fixed to reflect what the docs say. It looks like the DefaultGrailsConstraintClass is the problem:

public String getDefaultMessageCode() {
    String obj = (String)getPropertyValue(DEFAULT_MESSAGE_CODE_PROPERTY);
    if (obj == null) return "default.invalid." + getConstraintName() + ".message";
    return obj;
}

This line:

if (obj == null) return "default.invalid." + getConstraintName() + ".message";

should change to read:

if (obj == null) return "default."  + getConstraintName() + ".invalid.message";

jonroler avatar Mar 30 '13 07:03 jonroler