Skip to content

Instantly share code, notes, and snippets.

@manuelbernhardt
Created February 14, 2012 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelbernhardt/1826455 to your computer and use it in GitHub Desktop.
Save manuelbernhardt/1826455 to your computer and use it in GitHub Desktop.
val fieldConstraints = form.mapping.mappings.map(m => m.key -> m.constraints)
val tokenListMapping = list(
mapping(
"id" -> text,
"name" -> text,
"tokenType" -> optional (text),
"data" -> optional(of[Map[String, String]])
)(Token.apply)(Token.unapply)
)
val groupForm: Form[GroupViewModel] = Form(
mapping(
"id" -> optional(of[ObjectId]),
"name" -> nonEmptyText,
"grantType" -> nonEmptyText,
"canChangeGrantType" -> boolean,
"users" -> tokenListMapping.withPrefix ("users"),
"dataSets" -> tokenListMapping.withPrefix ("dataSets"),
"errors" -> of[Map[String, String]]
)(GroupViewModel.apply)(GroupViewModel.unapply)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment