validationgrailsgroovyconstraintsgrails-validation

Is it possible to use Grails validation outside of Grails? How?


Grails has amazing validation; is it possible to use it independent of the Grails framework?

We have a Java/Groovy Camel-based web application we can't convert to a Grails application. I'd love to use the Grails-style validation with the declarative constraints but have been unable to successfully configure the application to work with Grails libraries without converting the whole thing.


Solution

  • The validation provided by Grails is just a wrapper around Spring's bean validation framework. Since Grails is open source you can take a look at how it's done and adapt it to your own needs. The best place to start looking is the GrailsDomainClassValidator and DomainClassGrailsPlugin to get an idea of how it's done. Another point of interest would be the @Validateable AST annotation.

    As far as I know, and from what I can see in the source, there isn't a stand alone way to do this outside of a Grails project without writing your own adaptation/implementation.