title: Variable/custom error message in Play! 2 framework scala form
body: <p>I would like form validation in Play framework to produce a variable error message depending on collateral results of the validation. How can I do this cleanly?</p>
  
  <p>Specific example -- Say I have a form defined thus:</p>
  
  <pre><code>  val f = Form(
      "xml" -&gt; text
        .verifying(
          "xml is incorrect",
          xml =&gt; validationError(xml) == None
        )
    )
  
    def validationError(xml: String): Option[String]
  </code></pre>
  
  <p>What can I do to show the string returned by validationError as the validation error message, instead of the fixed string "xml is incorrect"?</p>