Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created July 25, 2011 13:13
Show Gist options
  • Select an option

  • Save olivermt/1104088 to your computer and use it in GitHub Desktop.

Select an option

Save olivermt/1104088 to your computer and use it in GitHub Desktop.
custom validator and scope
//the follow resides in Config.groovy
//custom validator that checks if a linked field is identical
confirmField(validator: { val, obj ->
String linkedField = propertyName + "Confirm" //the error line
if(obj.properties[linkedField] != val) {
return ['confirmField.mismatch']
}
return true
})
//gives error:
No signature of method: groovy.util.ConfigObject.plus() is applicable for argument types: (java.lang.String) values: [Confirm]
//How to reference the propertyName like in http://www.grails.org/doc/latest/ref/Constraints/validator.html ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment