boycod3
boycod3

Reputation: 5319

play framework form validation in scala

Working of play framework form validation in scala follows my Signup object, it gives me an error at the line "mapping(": "missing arguments for method mapping in object Forms; follow this method with `_' if you want to treat it as a partially applied function"

case class UserRegistration(username: String, password1: String, password2: String)

val loginForm = Form(
 mapping(
   "username" -> email,
   "password1" -> text,
   "password2" -> text
 )
 (UserRegistration.apply)(UserRegistration.unapply)
 verifying ("Passwords must match",  => f.password1 == f.password2)
)

Upvotes: 3

Views: 3794

Answers (2)

Tom Myer
Tom Myer

Reputation: 148

Using verifying on the entire "form backing object" doesn´t let you add errors to individual fields in the form. If you want to do that see Play! framework 2.0: Validate field in forms using other fields

Upvotes: 2

user2181408
user2181408

Reputation:

case class UserRegistration(username: String, password1: String, password2: String)

val loginForm = Form(
  mapping(
    "username" -> email,
    "password1" -> text,
    "password2" -> text
  )
  (UserRegistration.apply)(UserRegistration.unapply)
  verifying ("Passwords must match", f => f.password1 == f.password2)
)

your missing the ("Passwords must match", f => f.password1 == f.password2)

Upvotes: 6

Related Questions