Created
July 25, 2011 13:13
-
-
Save olivermt/1104088 to your computer and use it in GitHub Desktop.
custom validator and scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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