Grails/Groovy: Understanding the parameters of the closure code -


i'm new grails/groovy, , please bear me try understand piece of code had come across in book.

it simple album domain class:

class album {     string artist     string title     list songs = []     list durations = []       static constraints = {         artist blank: false         title blank: false         songs minsize:1, validator:{ val, obj ->             if(val.size() != obj.durations.size())                 return "songs.durations.not.equal.size"     } }   

my question comes constraints property block of code.
in validator constraint, author uses closure.
"val" , "obj"? values given?

also, bonus question, type "constraints"? don't think map defined [ ] in groovy. coming java perspective, x = { .. } array, i'm not sure same in groovy.

thanks help!

your first question, val , obj parameters refer value of property , pointer instance, respectively. documentation custom validation routines explains in further detail.

as bonus question constraints groovy closure.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -