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 ?
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With