"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Domain Classes/validate.html" (14 Sep 2022, 60803 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(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.allErrors.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.allErrors.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.