porno porno rokettube
Results 1 to 3 of 3

Thread: Add constraints to the elemets of List

  1. #1

    Add constraints to the elemets of List

    Is there are any possible way to add constraints to the elements of List? For example I have a command which accept List and I want add constraints on this elements, for example on size.

    class SongCommand {
        String title
        List<String> couplet
        List<String> chorus
        Boolean isChorus
        Boolean isChorusRepeat
        static constraints = {
            title(blank: false, maxSize: 6)
            isChorus(blank: true)
    How to do that?

    Thank you.

  2. #2
    I have the solution
    static constraints = {
      couplet(validator: { val ->
        boolean isValid = true 
        val.each {
          if (it.size() < 3) isValid = false
        return isValid
    It's not final, but as example. Better return error code message, not true/false.

  3. #3
    Administrator dave's Avatar
    Join Date
    Mar 2010
    West Yorkshire, UK - Valencia Spain
    Thanks for posting your solution.
    Connect with me on twitter : @davebrown1975

    Web & Mobile Development by Tucanoo Solutions Ltd

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Forum Design by Tucanoo Solutions Ltd Grails Development Specialists.