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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -