title: Spring controller Validation not working on HashSet of Objects
body: <p>I'm having trouble getting the @Valid annotation to fire in my Spring Controller.</p>
  <p>Basically I have the following class:</p>
  <pre><code>import lombok.Getter;
  import lombok.Setter;
  
  import javax.validation.constraints.NotBlank;
  
  @Getter
  @Setter
  public class PlayListDTO {
  
      @NotBlank(message = &quot;playListName is required&quot;)
      private String playListName;
      private String playListDescription;
      private String playListUrl;
      private String playListImageUrl;
  }
  </code></pre>
  <p>And the following controller:</p>
  <pre><code>   @PostMapping(path = &quot;&quot;)
      public PlayListUGC addPlayList(@RequestBody HashSet&lt;@Valid PlayListDTO&gt; playListDTO,
                                     Authentication authentication,
                                     @RequestHeader(name = &quot;Authorization&quot;) String token) {
          logger.info(&quot;Received Request to create new PlayList from User {}&quot;, authentication.getName());
          return playListService.savePlayList(playListDTO, authentication.getName());
      }
  </code></pre>
  <p>However if Post the following JSON the validation is not getting triggered:</p>
  <pre><code>[
    {
      &quot;playListName&quot;:&quot;&quot;,
      &quot;playListDescription&quot;:&quot;200&quot;,
      &quot;playListUrl&quot;:&quot;1234&quot;,
      &quot;playListImageUrl&quot;: &quot;playListImageUrl1&quot;
    },
    {
      &quot;playListName&quot;:&quot;asdadsad&quot;,
      &quot;playListDescription&quot;:&quot;500&quot;,
      &quot;playListUrl&quot;:&quot;1235&quot;,
      &quot;playListImageUrl&quot;: &quot;playListImageUrl&quot;
    }
  ]
  </code></pre>
  <p>Now, if I change my controller to take a RequestBody of just PlayListDTO the validation works i.e.</p>
  <pre><code>    @Operation(summary = &quot;Allows a logged in user to add a playlist&quot;)
      @PostMapping(path = &quot;&quot;)
      public PlayListUGC addPlayList(@RequestBody @Valid PlayListDTO playListDTO,
                                     Authentication authentication,
                                     @RequestHeader(name = &quot;Authorization&quot;) String token) {
          logger.info(&quot;Received Request to create new PlayList from User {}&quot;, authentication.getName());
          return playListService.savePlayList(playListDTO, authentication.getName());
      } 
  </code></pre>
  <p>Can anyone explain to me why the validation does not work when its on a HashSet collection?</p>
  <p>Thanks</p>