Skip to content
Type-safe Play Form Mappings for case classes by way of shapeless
Scala
Branch: master
Clone or download
This branch is 32 commits ahead, 15 commits behind tksfz:master.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src/main/scala/com/iterable/formless
.gitignore
LICENSE
README.md
build.sbt

README.md

play-formless

A library for defining and using the Play framework's HTML form mappings in a type-safe way using Shapeless.

Getting started

Add dependency

To try out play-formless in your own project, you'll need to build its JAR file (downloads from Maven Central coming soon).

$ git clone https://github.com/Iterable/play-formless.git
$ cd play-formless
$ sbt publishLocal

Then add the following library dependency to your project's build.sbt:

"com.iterable" %% "play-formless" % "0.1-SNAPSHOT"

Basic usage

Let's say we want to parse an HTML login form into the following case class:

case class Login(username: String, password: String)

We can create a SafeForm wrapper around Play's Form type:

import com.iterable.formless._
val safeForm = SafeForm.forCaseClass[Login].withDefaults(DefaultsWithNonEmptyText)

And then bind the form to requests as usual:

safeForm.bindFromRequest.fold(
  formWithErrors => handleErrors(formWithErrors),
  loginData => authenticate(loginData)
)
You can’t perform that action at this time.