geofflane/grails-constraints — pull request #13 by samcday (2012-01-25 11:13:00+00:00)
Title: Extend custom validate method return types

Hi Geoff,

Here's another pull request for you.

This one changes DefaultConstraintClass to return an Object from call to validate closure. The CustomConstraintFactory is then given the ol' copy/paste treatment, taking the same validate result handling from grails-core (org.codehaus.groovy.grails.validation.ValidatorConstraint).

This means that the validate method can now return the following:
* Nothing - which is interpreted as no validation errors
* True/false, as before
* String, which represents message code
* List, with first element being message code, and following elements being message parameters.

With this the validate closure behaves almost identically to regular custom validators (http://www.grails.org/doc/latest/ref/Constraints/validator.html). The only exception being that the Constraints plugin doesn't ignore return value if the validate closure accepts 3 parameters. Let me know how you feel about this.

There's also some tests written for this new functionality, with none of the original tests needing any changes.