title: Spring Boot - custom validation message with annotation parameters
body: <p>I want to create my custom validation messages with Spring Boot/MVC Validation. </p>
  
  <p>I found following setup working:</p>
  
  <pre><code>public class RegisterCredentials {
  
      @NotEmpty
      @NotNull
      @Size(min=3, max=15)
      private String username;
  
      ...
  
  }
  </code></pre>
  
  <p>messages.properties:</p>
  
  <pre><code>NotEmpty.registerCredentials.username = Username field cannot be empty.
  NotNull.registerCredentials.username = Username field cannot be empty.
  Size.registerCredentials.username = Username length must be between 3 and 15 characters.
  </code></pre>
  
  <p>After that I wanted to replace fixed values min=3 and max=15 with attributes. I tried like that, <strong>but it didn't worked</strong> (it works in @Size(message="..") annotation):</p>
  
  <pre><code>Size.registerCredentials.username = Username length must be between {min} and {max} characters.
  </code></pre>
  
  <p>Then I found following code working..:</p>
  
  <pre><code>Size.registerCredentials.username = Username length must be between {1} and {2} characters.
  </code></pre>
  
  <p>Well.. almost, because it produces following message:</p>
  
  <pre><code>Username length must be between 15 and 3 characters.
  </code></pre>
  
  <p>Replacing order of these {1} and {2} solves the problem, however it produces confusing code in futher analyze.</p>
  
  <p>Is there a solution to solve this problem with clean code?</p>