title: Different validations on same field based on active validation group
body: <p>I am trying to validate a request object using <code>Hibernate Validator</code>. </p>
  
  <p>As a simple example assume that the class of the object I am trying to validate has a <code>B bObj</code> field where <code>B</code> is another class that has a <code>String name</code> field . </p>
  
  <p>For that reason, I have implemented my own custom <code>Constraint Annotations</code> linked to custom <code>MyValidator implements ConstraintValidator</code> classes. </p>
  
  <p><strong>DTO class</strong></p>
  
  <pre><code>@AclassValidate(groups = {Operations.Insert.class, Operations.Update.class javax.validation.groups.Default.class})
  public class A {
  
      @BclassValidate(groups = {Operations.Insert.class, Operations.Update.class})
      private B bObj;
  
      // setters, getters
  }
  </code></pre>
  
  <p><strong>My endpoint method signature</strong> (where validator gets invoked, and the active group is set):</p>
  
  <pre><code>@PostMapping("/test")
  public A createA(
          @Validated(value = Operations.Insert.class) 
          // @Validated(value = Operations.Update.class) 
          @RequestBody A a
  )
  </code></pre>
  
  <p><strong>My validator class</strong></p>
  
  <pre><code>public class BclassValidator implements ConstraintValidator&lt;BclassValidate, B&gt; {
  
      public void initialize(BclassValidate constraintAnnotation) {
      }
  
      public boolean isValid(B b, ConstraintValidatorContext constraintContext) {
  
          boolean valid = true;
  
          // Get active group here
          activeGroup = ..?
          if (activeGroup == Operations.Insert.class) {
              // check if b.getName() equals to "John"
          }
          else if (activeGroup == Operations.Update.class) {
              // check if b.getName() equals to "Doe"
          }
  
          return valid;
      }
  }
  </code></pre>
  
  <p>What I want to achieve is to apply different validations for the same field based on the active group. The active group is the group, set at <code>@Validated</code> annotation. The question is how can I retrieve the active group in order to apply different validations based on its value?</p>