I'm only getting the default validator message. What am I doing wrong?
class Questao {
static hasMany = [alternativas:Alternativa]
static constraints = {
    alternativas (validator: {val, obj ->
       if(val.size() < 2)
            return ['validator.message'] //custom message
        })
}
}
/i18n
questao.alternativas.validator.message = "must be greater than two"
default.invalid.validator.message= Property [{0}] of class [{1}] with value [{2}] does not pass custom validation
Thanks
You're returning a list containing your message code - you need to return just the code:
alternativas validator: { val, obj ->
   if (val.size() < 2) {
      return 'validator.message' //custom message
   }
}
                        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