c

play.api.data

OptionalMapping

case class OptionalMapping[T](wrapped: Mapping[T], constraints: Seq[Constraint[Option[T]]] = Nil) extends Mapping[Option[T]] with Product with Serializable

A mapping for optional elements

wrapped

the wrapped mapping

Source
Form.scala
Linear Supertypes
Serializable, Product, Equals, Mapping[Option[T]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OptionalMapping
  2. Serializable
  3. Product
  4. Equals
  5. Mapping
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new OptionalMapping(wrapped: Mapping[T], constraints: Seq[Constraint[Option[T]]] = Nil)

    wrapped

    the wrapped mapping

Value Members

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

    Binds this field, i.e.

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

    data

    the submitted data

    returns

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

    Definition Classes
    Mapping
  2. val constraints: Seq[Constraint[Option[T]]]

    The constraints associated with this field.

    The constraints associated with this field.

    Definition Classes
    Mapping
  3. val format: Option[(String, Seq[Any])]

    The Format expected for this field, if it exists.

    The Format expected for this field, if it exists.

    Definition Classes
    Mapping
  4. val key: String

    The field key.

    The field key.

    Definition Classes
    Mapping
  5. val mappings: Seq[Mapping[_]]

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

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

    Definition Classes
    Mapping
  6. def productElementNames: Iterator[String]
    Definition Classes
    Product
  7. def transform[B](f1: (Option[T]) => B, f2: (B) => Option[T]): Mapping[B]

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

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

    B

    The type of the new mapping.

    f1

    Transform value of T to a value of B

    f2

    Transform value of B to a value of T

    Definition Classes
    Mapping
  8. def unbind(value: Option[T]): Map[String, String]

    Unbinds this field, i.e.

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

    value

    the value to unbind

    returns

    the plain data

    Definition Classes
    Mapping
  9. def unbindAndValidate(value: Option[T]): (Map[String, String], Seq[FormError])

    Unbinds this field, i.e.

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

    value

    the value to unbind

    returns

    the plain data and any errors in the plain data

    Definition Classes
    Mapping
  10. def verifying(addConstraints: Constraint[Option[T]]*): Mapping[Option[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) )
    addConstraints

    the constraints to add

    returns

    the new mapping

    Definition Classes
    Mapping
  11. def verifying(error: => String, constraint: (Option[T]) => Boolean): Mapping[Option[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}))
    error

    The error message used if the constraint fails

    constraint

    a function describing the constraint that returns false on failure

    returns

    the new mapping

    Definition Classes
    Mapping
  12. def verifying(constraint: (Option[T]) => Boolean): Mapping[Option[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})
    constraint

    a function describing the constraint that returns false on failure

    returns

    the new mapping

    Definition Classes
    Mapping
  13. def withPrefix(prefix: String): Mapping[Option[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.

    prefix

    the prefix to add to the key

    returns

    the same mapping, with only the key changed

    Definition Classes
    Mapping
  14. val wrapped: Mapping[T]