(Quick Reference)



Validates a domain class against the applied constraints (see Validation)


The validate method will validate a domain class based on its defined constraints. The errors will be stored within the errors object.

The validate method accepts an optional List argument which may contain the names of the properties that should be validated. When a List is passed to the validate method, only the properties defined in the List will be validated.


def b = new Book(title:"The Shining")
if( !b.validate() ) {
   b.errors.each {
        println it

def a = new Album(artist: "Genesis", title: "Nursery Cryme", releaseDate: 1971)

// only validate title and releaseDate if( !a.validate(["title", "releaseDate"]) ) { a.errors.each { println it } }


  • deepValidate (optional) - Determines whether associations of the domain instance should also be validated, i.e. whether validation cascades or not. This is true by default - set to false to disable cascading validation.