(Quick Reference)



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


The validate method validates a domain class based on its defined constraints. The errors are stored in the errors property of the domain class instance.

The validate method accepts an optional List argument which contains the names of the properties to be validated. When a List of names is specified, only those properties 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) - Whether associations of the domain instance should also be validated, i.e. whether validation cascades. This is true by default; set it to false to disable cascading validation.