title: How to validate a configuration property only if a certain profile is active?
body: <p>Is there a way to expect a property not to be null, only if a certain profile is active?</p>
  
  <pre class="lang-java prettyprint-override"><code>@Data
  @Component
  @ConfigurationProperties(prefix = "sample")
  @Validated
  public class SampleProperties {
  
      @NotNull
      private String sample1;
  
      @NotNull
      @Valid
      private MoreProperties more = new MoreProperties()
  
  
      @Data
      public static class MoreProperties {
  
          @NotNull // ← This should not be null only if the prod profile is active
          private String sample2;
  
      }
  }
  </code></pre>