I'm new to Grails/Groovy, and so please bear with me as I try to understand a piece of code that I had come across in a book.
It is a 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 from the constraints property block of code.
In the validator constraint, the author uses a closure.
But what exactly are "val" and "obj"? What values will they be given?
Also, a bonus question, what type is "constraints"? I don't think it is a map as they are defined as [ ] in Groovy. Coming from a Java perspective, x = { .. } is an array, but I'm not sure it is the same in Groovy.
Thanks for the help!