I followed the instruction here: http://www.grails.org/doc/latest/guide/7.%20Validation.html
and added into config.groovy:
grails.valida
You really need to call validate()
before - it will trigger validation and change object state. Looking at ValidationGrailsPlugin.addValidationMethods()
, I see that hasErrors() is a read-only method.
Your sample worked for me after calling validate(). I tried in grails console
(great tool, I highly recommend it!):
Warm w = new Warm('')
w.hasErrors() // 'Result: false'
w.validate()
w.hasErrors() // 'Result: true'
I added @Validateable
to Warm class. I believe it makes no difference.
I don't think the validate()
and hasErrors()
dynamic methods are added in a Unit test. If you move this to an integration test they should be there.