Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grails : how to validate single field in command object

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 ?

like image 713
knocker_d Avatar asked Dec 20 '22 10:12

knocker_d


1 Answers

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
    }
}
like image 94
aiolos Avatar answered Feb 08 '23 01:02

aiolos