title: Best way to validate and extend constructor parameters in Scala 2.10
body: <p>I want to have a class that has a number of fields such as String, Boolean, etc and when the class is constructed I want to have a fieldname associated with each field and verify the field (using regex for strings). Ideally I would just like specify in the constructor that the parameter needs to meet certain criteria.</p>
  
  <p>Some sample code of how :
  </p>
  
  <pre class="lang-scala prettyprint-override"><code>case class Data(val name: String ..., val fileName: String ...) {
    name.verify
    // Access fieldName associated with the name parameter.
    println(name.fieldName) // "Name"
    println(fileName.fieldName) // "File Name"
  }
  
  val x = Data("testName", "testFile")
  // Treat name as if it was just a string field in Data
  x.name // Is of type string, does not expose fieldName, etc
  </code></pre>
  
  <p>Is there an elegant way to achieve this?</p>
  
  <p>EDIT:
  I don't think I have been able to get across clearly what I am after. 
  I have a class with a number of string parameters. Each of those parameters needs to validated in a specific way and I also want to have a string fieldName associated with each parameter. However, I want to still be able to treat the parameter as if it was just a normal string (see the example).</p>
  
  <p>I could code the logic into Data and as an apply method of the Data companion object for each parameter, but I was hoping to have something more generic.</p>