title: Checking the number of digits in Scala
body: <p>I need to to check whether the number of digits in a number are equal to some other number. The best way I could come up with was this:</p>
  
  <pre><code>require(Number.toString  == """\d{8}""", throw new InvalidDateFormatException("Wrong format for string parameter"))
  </code></pre>
  
  <p>where the number of digits required are 8. Is there any better way?</p>