title: Java Bean validation and regex - format and length in two different error message
body: <p>For example, input is phone number. Format is </p>
  
  <p>(country code)(space)(area code)(space)(phone number)</p>
  
  <p>Area code can be blank.</p>
  
  <pre><code>e.g.
  63 240 1234567   (valid)
  63 1234567  (valid)
  </code></pre>
  
  <p>What regex pattern do I need so I can have it check if all characters are numeric and if the phone number (without country and area code) is of a certain length?</p>
  
  <p>and is it possible that using only one pattern, I can have two distinct error messages for two distinct invalid input:
  1. All characters should be numeric
  2. Actual Phone number length should be 7 to 10. </p>
  
  <p>because we currently have it this way</p>
  
  <pre><code>@Pattern(regexp=" some regex pattern", message="phone is invalid")
  private String phoneNumber
  </code></pre>
  
  <p>I could add a @Size validator but I only need to trim out the phone number.</p>
  
  <p>Can anyone help? </p>