Uploaded image for project: 'BVal'
  1. BVal
  2. BVAL-47

Correctly follow GroupSequence definitions when validating

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.1-incubating
    • 0.2-incubating
    • jsr303
    • None

    Description

      I'm submitting this here for review as the solution involves many structural changes in ClassValidator. If you think the patch is fine, I can merge it once I get commit access.

      Basically, when validating the default group in a bean:

      • If a group sequence is defined in the bean class, iterate that sequence and stop if any violation is found.
      • If no group sequence is defined in the bean class, get the hierarchy of classes in the bean, and for each class, check the constraints defined in that class or interface according to the group sequence defined in that class.

      The same algorithm must be applied to related beans (@Valid), and validation starts again from the default group for them (groups defined in the group sequence of their parent bean must not be applied to their related beans).

      I added 2 additional tests, those and the TCK tests in GroupSequenceIsolationTest should help clarify the spec regarding this.

      Resulting ClassValidator is quite decoupled from BeanValidator (the class it inherits from, in bval-core). Some of the methods are similar in code, but the order in which they are called differs, so overriding wasn't an option. It could be an option to completely remove inheritance in the future to obtain a cleaner ClassValidator.

      Attachments

        1. bval-jsr303-47.patch
          36 kB
          Carlos Vara
        2. bval-core-47.patch
          3 kB
          Carlos Vara

        Activity

          People

            Unassigned Unassigned
            carlos.vara Carlos Vara
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: