Custom validation logic for parameter in REST endpoint Spring Boot
<p>I currently have this <code>RequestMapping</code> where I use validation through a regular expression:</p>

<pre><code> @RequestMapping(value = "/example/{id}", method = GET)
 public Response getExample(
         @PathVariable("id") String id,
         @RequestParam(value = "myParam", required = true) @Valid @Pattern(regexp = MY_REGEX) String myParamRequest,
         @RequestParam(value = "callback", required = false) String callback,
         @RequestHeader(value = "X-API-Key", required = true) @Valid @Pattern(regexp = SEGMENTS_REGEX) String apiKeyHeader) {

     // Stuff here...
 }
</code></pre>

<p>However, the regulare expression is not enough. Instead, I would like to do some custom validation on the header attribute i.e.</p>

<pre><code>if (!API_KEY_LIST.contains(apiKeyHeader)) {
    throw Exception();
}
</code></pre>

<p>Is this possible?</p>