Mapping

play.api.data.Mapping
trait Mapping[T]

A mapping is a two-way binder to handle a form field.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class FieldMapping[T]
class ObjectMapping1[R, A1]
class ObjectMapping10[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]
class ObjectMapping11[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11]
class ObjectMapping12[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12]
class ObjectMapping13[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13]
class ObjectMapping14[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14]
class ObjectMapping15[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15]
class ObjectMapping16[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16]
class ObjectMapping17[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17]
class ObjectMapping18[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18]
class ObjectMapping19[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19]
class ObjectMapping2[R, A1, A2]
class ObjectMapping20[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20]
class ObjectMapping21[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21]
class ObjectMapping22[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22]
class ObjectMapping3[R, A1, A2, A3]
class ObjectMapping4[R, A1, A2, A3, A4]
class ObjectMapping5[R, A1, A2, A3, A4, A5]
class ObjectMapping6[R, A1, A2, A3, A4, A5, A6]
class ObjectMapping7[R, A1, A2, A3, A4, A5, A6, A7]
class ObjectMapping8[R, A1, A2, A3, A4, A5, A6, A7, A8]
class ObjectMapping9[R, A1, A2, A3, A4, A5, A6, A7, A8, A9]
class OptionalMapping[T]
class RepeatedMapping[T]
class WrappedMapping[A, B]
Show all
Self type
Mapping[T]

Members list

Value members

Abstract methods

def bind(data: Map[String, String]): Either[Seq[FormError], T]

Binds this field, i.e. construct a concrete value from submitted data.

Binds this field, i.e. construct a concrete value from submitted data.

Value parameters

data

the submitted data

Attributes

Returns

either a concrete value of type T or a set of errors, if the binding failed

The constraints associated with this field.

The constraints associated with this field.

Attributes

def key: String

The field key.

The field key.

Attributes

def mappings: Seq[Mapping[_]]

Sub-mappings (these can be seen as sub-keys).

Sub-mappings (these can be seen as sub-keys).

Attributes

def unbind(value: T): Map[String, String]

Unbinds this field, i.e. transforms a concrete value to plain data.

Unbinds this field, i.e. transforms a concrete value to plain data.

Value parameters

value

the value to unbind

Attributes

Returns

the plain data

Unbinds this field, i.e. transforms a concrete value to plain data, and applies validation.

Unbinds this field, i.e. transforms a concrete value to plain data, and applies validation.

Value parameters

value

the value to unbind

Attributes

Returns

the plain data and any errors in the plain data

def verifying(constraints: Constraint[T]*): Mapping[T]

Constructs a new Mapping based on this one, by adding new constraints.

Constructs a new Mapping based on this one, by adding new constraints.

For example:

 import play.api.data._
 import validation.Constraints._

 Form("phonenumber" -> text.verifying(required) )

Value parameters

constraints

the constraints to add

Attributes

Returns

the new mapping

def withPrefix(prefix: String): Mapping[T]

Constructs a new Mapping based on this one, adding a prefix to the key.

Constructs a new Mapping based on this one, adding a prefix to the key.

Value parameters

prefix

the prefix to add to the key

Attributes

Returns

the same mapping, with only the key changed

Concrete methods

protected def addPrefix(prefix: String): Option[String]
protected def applyConstraints(t: T): Either[Seq[FormError], T]
protected def collectErrors(t: T): Seq[FormError]
def format: Option[(String, Seq[Any])]

The Format expected for this field, if it exists.

The Format expected for this field, if it exists.

Attributes

def transform[B](f1: T => B, f2: B => T): Mapping[B]

Transform this Mapping[T] to a Mapping[B].

Transform this Mapping[T] to a Mapping[B].

Type parameters

B

The type of the new mapping.

Value parameters

f1

Transform value of T to a value of B

f2

Transform value of B to a value of T

Attributes

def verifying(constraint: T => Boolean): Mapping[T]

Constructs a new Mapping based on this one, by adding a new ad-hoc constraint.

Constructs a new Mapping based on this one, by adding a new ad-hoc constraint.

For example:

 import play.api.data._
 import validation.Constraints._

 Form("phonenumber" -> text.verifying {_.grouped(2).size == 5})

Value parameters

constraint

a function describing the constraint that returns false on failure

Attributes

Returns

the new mapping

def verifying(error: => String, constraint: T => Boolean): Mapping[T]

Constructs a new Mapping based on this one, by adding a new ad-hoc constraint.

Constructs a new Mapping based on this one, by adding a new ad-hoc constraint.

For example:

 import play.api.data._
 import validation.Constraints._

 Form("phonenumber" -> text.verifying("Bad phone number", {_.grouped(2).size == 5}))

Value parameters

constraint

a function describing the constraint that returns false on failure

error

The error message used if the constraint fails

Attributes

Returns

the new mapping