Custom validation of Play 2.0 form (scala) -


i'm writing little hobby app. now, in application want people have userid (just mine niklassaers here on stack overflow), , if taken, want user error can select another.

here follows signup object, gives me error @ line "mapping(": "missing arguments method mapping in object forms; follow method `_' if want treat partially applied function"

object signup extends controller {    val userform: form[userprofile] = form(     mapping(       "userid" -> nonemptytext,       "passwordhash" -> nonemptytext,       "email" -> email     ) verifying (       "thisisatest", { case(userid, passwordhash, email) => true }       // "userid taken", { dbservice.exists(userprofile.getclass().getname(), userid) }       )(userprofile.apply)(userprofile.unapply))     def index = action {      ok(views.html.signup(userform))   }    def register = action { implicit request =>     userform.bindfromrequest.fold(       errors => badrequest(views.html.signup(errors)),       user => redirect(routes.profile.index))   } } 

as can see, i've replaced lookup service test verification returns true, make example less complex. completeness, userdetail case class:

case class userprofile(                    userid : string,                    email: string,                    passwordhash: string) 

i'm scala newbie , play newbie, i'm sorry if trivial question. but:

  1. what doing wrong since error?

  2. is right way of adding own validation?

  3. follow-up question: redirect if goes well, how should redirect page referencing verified form?

cheers

nik

finally got around this: verifying isn't comes after mapping, comes @ constraint. should be

"userid" -> nonemptytext.verifying( "userid taken", userid => dbservice.exists(userprofile.getclass().getname().replace("$", ""), userid) == false ), 

i hope helps others have same problem :-)


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -