如何在游戏中验证另一个表单输入?

时间:2014-03-05 14:32:52

标签: forms scala input playframework-2.0

这是我基于示例的代码:

val signupForm = Form(
    tuple(
      "firstname" -> nonEmptyText,
      "lastname"  -> nonEmptyText,
      "email"     -> nonEmptyText,
      "password1" -> nonEmptyText,
      "password2" -> nonEmptyText,
      "phone"     -> optional(text)
    )   verifying ("That email address already exists please contact an administrator.", result => result match {
      case (firstname, lastname, email, password1, password2, phone) => !User.checkexists(email).isDefined 
    })
    )

但是没有示例显示我可以在那里添加另一张支票 - 例如比较密码1& password2 ......或第三次检查...

我可以在哪里添加另一个'验证'位?

感谢

1 个答案:

答案 0 :(得分:2)

val signupForm = Form(
  tuple(
    ...
  ) verifying (...)
  verifying (...)
  verifying (...)
)

在你的情况下:

val signupForm = Form(
  tuple(
    "firstname" -> nonEmptyText,
    "lastname"  -> nonEmptyText,
    "email"     -> nonEmptyText,
    "password1" -> nonEmptyText,
    "password2" -> nonEmptyText,
    "phone"     -> optional(text)
  )   verifying ("That email address already exists please contact an administrator.", result => result match {
    case (firstname, lastname, email, password1, password2, phone) => !User.checkexists(email).isDefined 
  })
  verifying (...)
)