title: Validate an object in 2 microservices with different requirements
body: <p>I've been looking for info about this but nothing found, so I will try to explain it correctly:
  We have a Class, <code>rqtDto.class</code> used in a parent library. This class has the next code:</p>
  <pre><code>@Getter
  @Setter
  @SuperBuilder
  @NoArgsConstructor
  @AllArgsConstructor
  @GroupSequence({ Security.class, Validations.class, Functionals.class,
          rqtDto.class })
  public class rqtDto {
  
      /**
       * Unique Identifier.
       */
      @CyberSecurity(groups = Security.class)
      @NotBlank(groups = Validations.class, message = &quot;blank&quot;)
      @Size(min = 0, max = 32, groups = Validations.class, message = &quot;invalid data&quot;)
      @myId(groups = Functionals.class)
      private String myId;
  
      @CyberSecurity(groups = Security.class)
      @NotNull(groups = Validations.class, message = &quot;is null&quot;)
      @Enumeration(enumClazz = MyEnum.class, groups = Functionals.class, message = &quot;not allowed&quot;)
      private String enumResult;
  
      @Builder.Default
      @CyberSecurity(groups = Security.class)
      @Enumeration(enumClazz = EnumValidation.class, groups = Functionals.class, message = &quot;not allowed&quot;)
      private String myEnumValidation = EnumValidation.ALL.getCode();
  
      @Valid
      @NotEmpty(groups = Validations.class, message = &quot;empty&quot;)
      private Collection&lt;ClientsDto&gt; clients;
  }
  </code></pre>
  <p>So, this class is the input in our main microservice.
  All validations are OK, but, in some point, we have to send it to another microservice.
  This microservice will use only some of those fields to call to a external service, but we have to validate those fields.</p>
  <p>We was thinking in create some annotations like the ones contained in next code to validate only some fields from the <code>rqtDto</code> class in the second, third, fourth microservice:</p>
  <pre><code>public class rqtDto {
  
      /**
       * Unique Identifier.
       */
      @CyberSecurity(groups = Security.class)
      @NotBlank(groups = Validations.class, message = &quot;blank&quot;)
      @Size(min = 0, max = 32, groups = Validations.class, message = &quot;invalid data&quot;)
      @myId(groups = Functionals.class)
      @ValidateInSecondMicroservice //new @, this property must be validated in the second Microservice
      private String myId;
  
      @CyberSecurity(groups = Security.class)
      @NotNull(groups = Validations.class, message = &quot;is null&quot;)
      @Enumeration(enumClazz = MyEnum.class, groups = Functionals.class, message = &quot;not allowed&quot;)
      private String enumResult; // this property has not @ValidateInSecondMicroservice, so this property must not be validated in the second microservice.
  </code></pre>
  <p>So the problem is: how can I switch on/off the validation of some fields in the second, third, fourth microservice, and have a full object validation in the first microservice?</p>
  <p>I was reading about this in the jboss documentation, but the &quot;most approximately solution&quot; I got was: create a new object with new validations but extended from the <code>rqtDto.class</code>.
  But that's not possible, must be the same class, located in the main library, used by all the rest of the microservices.</p>