{"id":1716,"date":"2010-09-15T00:54:12","date_gmt":"2010-09-14T19:24:12","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1716"},"modified":"2016-12-19T15:28:30","modified_gmt":"2016-12-19T09:58:30","slug":"grails-annotation-validateable","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/grails-annotation-validateable\/","title":{"rendered":"Grails annotation &#8211; Validateable"},"content":{"rendered":"<p>We can easily validate domain classes and command objects using static constraints. But how about validating DTOs or any groovy class in src\/groovy folder.<br \/>\n<\/p>\n<p>The answer is YES, they can be validated too. Follow two simple steps:<\/p>\n<p>1. Add annotation &#8216;@Validateable&#8217; above the class.<br \/>\n2. Declare the package to be validated in Config.groovy as:<br \/>\n<\/p>\n<pre lang=\"groovy\">\r\ngrails.validateable.packages = ['com.mycompany.dto']\r\n<\/pre>\n<p>Click <a href=\"http:\/\/www.grails.org\/doc\/1.3.4\/guide\/7.%20Validation.html#7.5%20Validation%20Non%20Domain%20and%20Command%20Object%20Classes\">here<\/a> to read complete documentation.<\/p>\n<p>I wish I knew this earlier. Grails rocks!!<br \/>\n\u2013<br \/>\n~Aman Aggarwal<br \/>\n<a href=\"mailto:aman@intelligrape.com\">aman@intelligrape.com<\/a><\/p>\n<p><a href=\"http:\/\/www.tothenew.com\/blog\/\">http:\/\/www.IntelliGrape.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can easily validate domain classes and command objects using static constraints. But how about validating DTOs or any groovy class in src\/groovy folder. The answer is YES, they can be validated too. Follow two simple steps: 1. Add annotation &#8216;@Validateable&#8217; above the class. 2. Declare the package to be validated in Config.groovy as: grails.validateable.packages [&hellip;]<\/p>\n","protected":false},"author":282,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1716"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/282"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1716"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1716\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}