{"id":35157602,"url":"https://github.com/gpc/grails-cascade-validation","last_synced_at":"2026-05-21T19:35:08.688Z","repository":{"id":45609040,"uuid":"165618373","full_name":"gpc/grails-cascade-validation","owner":"gpc","description":"Establishes a 'cascade' constraint property for validateable objects. If \"cascade:true\" is set on a nested object, the nested object's validate() method will be invoked and the results will be reported as part of the parent object's validation. Based on a blog post by Eric Kelm:  http://asoftwareguy.com/2013/07/01/grails-cascade-validation-for-pogos/ Used with permission.","archived":false,"fork":false,"pushed_at":"2026-05-07T07:03:54.000Z","size":967,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"7.0.x","last_synced_at":"2026-05-07T09:06:51.071Z","etag":null,"topics":["cascade-validation","command-object","grails","grails-cascade-validation","grails-plugin","validate"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rmorrise/grails-cascade-validation","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gpc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-01-14T07:50:30.000Z","updated_at":"2026-05-07T07:00:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gpc/grails-cascade-validation","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gpc/grails-cascade-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgrails-cascade-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgrails-cascade-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgrails-cascade-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgrails-cascade-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gpc","download_url":"https://codeload.github.com/gpc/grails-cascade-validation/tar.gz/refs/heads/7.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpc%2Fgrails-cascade-validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33311871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cascade-validation","command-object","grails","grails-cascade-validation","grails-plugin","validate"],"created_at":"2025-12-28T17:04:32.250Z","updated_at":"2026-05-21T19:35:08.676Z","avatar_url":"https://github.com/gpc.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/io.github.gpc/cascade-validation)](https://central.sonatype.com/artifact/io.github.gpc/cascade-validation)\n[![CI](https://github.com/gpc/grails-cascade-validation/actions/workflows/gradle.yml/badge.svg?event=push)](https://github.com/gpc/grails-cascade-validation/actions/workflows/gradle.yml)\n\nGrails Cascade Validation\n=========================\n\nThis plugin establishes a `cascade` constraint property for validatable objects, that being domain objects, and objects implementing `grails.validation.Validateable`. If `cascade:true` is set on a nested object, the nested object's `validate()`  method will be invoked and the results will be reported as part of the parent object's validation.\n\nThis plugin is for Grails 7.0.0\n\n### **BREAKING CHANGE**\n\nThe `cascade` constraint in `constraints` was renamed to `cascaded` because of a name clash with Hibernate cascading.\n\nTo use this plugin, add the plugin to `build.gradle`:\n\n```groovy \ndependencies {\n     implementation \"io.github.gpc:cascade-validation:7.0.1\"\n}\n```\n\nHere is an example of a command object that uses the plugin:\n```groovy\nclass Person implements Validateable {\n    String firstName\n    String lastName\n    List\u003cPhoneNumber\u003e phones\n    \n    static constraints = {\n        phones cascaded: { value -\u003e value.isPrimary } // Only validate the phonenumber if the value is a primary number\n    }\n}\n```\n\n\n```groovy\n class PhoneNumber implements Validateable {\n     long id\n     String countryCode\n     String areaCode\n     String number\n     String extension\n     TelephoneType telephoneType\n     boolean isPrimary\n\n     static constraints = {\n         areaCode(nullable: false)\n         number(nullable: false)\n         telephoneType(cascaded: true)\n     }\n\n     static class TelephoneType implements Validateable {\n         String id\n         boolean countryCodeRecommended\n\n         static constraints = {\n             id(nullable: false)\n             countryCodeRecommended(nullable: false)\n         }\n     }\n }\n```\n\nWhen the `cascade:` constraint is added on the `telephoneType`  property, this enables nested validation. When the `phoneNumber.validate()` method is called, the `telephoneType.validate()` method will also be invoked. Field errors that are added to the `telephoneType` will also be added to the parent `phoneNumber` object.\n\nThis plugin was originally based on a blog post by Eric Kelm and is used here with Eric's permission.\n\n*NOTE:*\n\nWhen running a unit test, the cascade constraint isn't registered with Grails. To work around this issue, the test class must implement\n`org.grails.testing.GrailsUnitTest` and the following code must be added to the `setup()` method of the test:\n\n```groovy\nimport grails.cascade.validation.internal.CascadeConstraintRegistration\nimport org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEvaluator\nimport org.grails.testing.GrailsUnitTest\nimport spock.lang.Specification\n\nclass ParentSpec extends Specification implements GrailsUnitTest {\n\n    Closure doWithSpring() {\n        return {\n            constraintEvaluator(DefaultConstraintEvaluator)\n        }\n    }\n\n    void setup() {\n        // Important for Unit-tests as the registrations only happens when Grails context is started.\n        CascadeConstraintRegistration.register(applicationContext)\n    }\n\n    void 'validate cascade'() {\n        given:\n        def phone = new PhoneNumber(telephoneType: new PhoneNumber.TelephoneType())\n\n        when:\n        phone.validate(['telephoneType'])\n\n        then:\n        phone.hasErrors()\n\n        parent.errors.getFieldError('telephoneType.id').code == 'nullable'\n        parent.errors.getFieldError('telephoneType.countryCodeRecommended').code == 'nullable'\n    }\n}\n\n```\nThis will register the `CascadeConstraint` the same way as the plugin does at runtime.\n\nSee the full documentation here: https://gpc.github.io/grails-cascade-validation/snapshot/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpc%2Fgrails-cascade-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpc%2Fgrails-cascade-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpc%2Fgrails-cascade-validation/lists"}