Reputation: 566
I want to manually validate field in command object
I know I can get field's max value (and min) with this:
MyDomain.constraints.myField.getAppliedConstraint('max').maxValue
How can I execute 'validate' command on 'myField' and get errors object ?
Upvotes: 5
Views: 2734
Reputation: 4697
Have a look at the grails docs.
You could use the validate()
method on a defined list of properties:
if(!yourObject.validate(['myField'])) {
yourObject.errors.each {
println it
}
}
Upvotes: 11