Uploaded image for project: 'Hibernate Validator'
  1. HV-1057

Group sequences don't honor inheritance relationships properly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.2.4.Final, 5.3.0.CR1
    • Component/s: engine
    • Labels:
      None

      Description

      Group sequences may contain groups which are inherited from another group:

      public class Try {
      
          @NotNull(message = "field1", groups = BaseComponent.class)
          public String field1;
      
          @NotNull(message = "field2", groups = Component.class)
          public String field2;
      
          @NotNull(message = "field3", groups = OtherComponent.class)
          public String field3 = "";
      
          public interface BaseComponent {}
          public interface Component extends BaseComponent {}
          public interface OtherComponent {}
      
          @GroupSequence({ Component.class, OtherComponent.class })
          public interface GlobalCheck {}
      }
      

      A validation validator.validate( new Try(), Try.GlobalCheck.class ); should yield the two constraints on field1 and field2 (as both constraints are in the Component group, which extends the BaseComponent group.

      The current implementation returns only the constraint on field2, though. The reason being that all three groups which form the sequence are "flattened out", thus loosing the information that Component and BaseComponent need to be considered as one atomic unit here.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gunnar.morling Gunnar Morling
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: