Play 2.0 form - field "verifying" method is not a member
playframework-2.0, scala, validation
Solution
According to Scala operators precedence rules, methods starting with a letter have a lower precedence than others so when you write:
"age" -> number verifying (min(0), max(100))
The compiler builds the following expression:
("age" -> number) verifying (min(0), max(100))
Which is not what you want! You can rewrite it as follows:
"age" -> number.verifying(min(0), max(100))
"age" -> (number verifying (min(0), max(100)))
And the current Play documentation is wrong. Thanks for catching it!
Problem
Practicing what is written here: ScalaForms, I have created the following form: ``` val personCreationForm = Form( tuple ( "name" -> nonEmptyText, "age" -> number verifying (min(0), max(100)) /*ERROR*/ ) verifying ("Wrong entry", result => result match { case (name, age) => true }) ) ``` However, the error on `verifying` states that `value verifying is not a member of (java.lang.String, play.api.data.Mapping[Int])`. Working with `mapping` instead of `tuple`, as in the referenced example, makes no difference. What is wrong here?