Package

play.api

data

Permalink

package data

Contains data manipulation helpers (typically HTTP form handling)

import play.api.data._
import play.api.data.Forms._

val taskForm = Form(
  tuple(
    "name" -> text(minLength = 3),
    "dueDate" -> date("yyyy-MM-dd"),
    "done" -> boolean
  )
)
Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. data
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class Field(form: Form[_], name: String, constraints: Seq[(String, Seq[Any])], format: Option[(String, Seq[Any])], errors: Seq[FormError], value: Option[String]) extends Product with Serializable

    Permalink

    A form field.

    A form field.

    name

    the field name

    constraints

    the constraints associated with the field

    format

    the format expected for this field

    errors

    the errors associated to this field

    value

    the field value, if any

  2. case class FieldMapping[T](key: String = "", constraints: Seq[Constraint[T]] = Nil)(implicit binder: Formatter[T]) extends Mapping[T] with Product with Serializable

    Permalink

    A mapping for a single field.

    A mapping for a single field.

    key

    the field key

    constraints

    the constraints associated with this field.

  3. case class Form[T](mapping: Mapping[T], data: Map[String, String], errors: Seq[FormError], value: Option[T]) extends Product with Serializable

    Permalink

    Helper to manage HTML form description, submission and validation.

    Helper to manage HTML form description, submission and validation.

    For example, a form handling a User case class submission:

    import play.api.data._
    import play.api.data.Forms._
    import play.api.data.format.Formats._
    
    val userForm = Form(
      mapping(
        "name" -> of[String],
        "age" -> of[Int],
        "email" -> of[String]
      )(User.apply)(User.unapply)
    )
    T

    the type managed by this form

    mapping

    the form mapping, which describes all form fields

    data

    the current form data, used to display the form

    errors

    the collection of errors associated with this form

    value

    a concrete value of type T if the form submission was successful

  4. case class FormError(key: String, messages: Seq[String], args: Seq[Any] = Nil) extends Product with Serializable

    Permalink

    A form error.

    A form error.

    key

    The error key (should be associated with a field using the same key).

    messages

    The form message (often a simple message key needing to be translated), if more than one message is passed the last one will be used.

    args

    Arguments used to format the message.

  5. trait Mapping[T] extends AnyRef

    Permalink

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

  6. trait ObjectMapping extends AnyRef

    Permalink

    Common helper methods for all object mappings - mappings including several fields.

  7. class ObjectMapping1[R, A1] extends Mapping[R] with ObjectMapping

    Permalink
  8. class ObjectMapping10[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10] extends Mapping[R] with ObjectMapping

    Permalink
  9. class ObjectMapping11[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11] extends Mapping[R] with ObjectMapping

    Permalink
  10. class ObjectMapping12[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12] extends Mapping[R] with ObjectMapping

    Permalink
  11. class ObjectMapping13[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13] extends Mapping[R] with ObjectMapping

    Permalink
  12. class ObjectMapping14[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14] extends Mapping[R] with ObjectMapping

    Permalink
  13. class ObjectMapping15[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15] extends Mapping[R] with ObjectMapping

    Permalink
  14. class ObjectMapping16[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16] extends Mapping[R] with ObjectMapping

    Permalink
  15. class ObjectMapping17[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17] extends Mapping[R] with ObjectMapping

    Permalink
  16. class ObjectMapping18[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18] extends Mapping[R] with ObjectMapping

    Permalink
  17. class ObjectMapping19[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19] extends Mapping[R] with ObjectMapping

    Permalink
  18. class ObjectMapping2[R, A1, A2] extends Mapping[R] with ObjectMapping

    Permalink
  19. class ObjectMapping20[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20] extends Mapping[R] with ObjectMapping

    Permalink
  20. class ObjectMapping21[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21] extends Mapping[R] with ObjectMapping

    Permalink
  21. 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] extends Mapping[R] with ObjectMapping

    Permalink
  22. class ObjectMapping3[R, A1, A2, A3] extends Mapping[R] with ObjectMapping

    Permalink
  23. class ObjectMapping4[R, A1, A2, A3, A4] extends Mapping[R] with ObjectMapping

    Permalink
  24. class ObjectMapping5[R, A1, A2, A3, A4, A5] extends Mapping[R] with ObjectMapping

    Permalink
  25. class ObjectMapping6[R, A1, A2, A3, A4, A5, A6] extends Mapping[R] with ObjectMapping

    Permalink
  26. class ObjectMapping7[R, A1, A2, A3, A4, A5, A6, A7] extends Mapping[R] with ObjectMapping

    Permalink
  27. class ObjectMapping8[R, A1, A2, A3, A4, A5, A6, A7, A8] extends Mapping[R] with ObjectMapping

    Permalink
  28. class ObjectMapping9[R, A1, A2, A3, A4, A5, A6, A7, A8, A9] extends Mapping[R] with ObjectMapping

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

    Permalink

    A mapping for optional elements

    A mapping for optional elements

    wrapped

    the wrapped mapping

  30. case class RepeatedMapping[T](wrapped: Mapping[T], key: String = "", constraints: Seq[Constraint[List[T]]] = Nil) extends Mapping[List[T]] with Product with Serializable

    Permalink

    A mapping for repeated elements.

    A mapping for repeated elements.

    wrapped

    The wrapped mapping

  31. case class WrappedMapping[A, B](wrapped: Mapping[A], f1: (A) ⇒ B, f2: (B) ⇒ A, additionalConstraints: Seq[Constraint[B]] = Nil) extends Mapping[B] with Product with Serializable

    Permalink

    A mapping wrapping another existing mapping with transformation functions.

    A mapping wrapping another existing mapping with transformation functions.

    wrapped

    Existing wrapped mapping

    f1

    Transformation function from A to B

    f2

    Transformation function from B to A

    additionalConstraints

    Additional constraints of type B

Value Members

  1. object Form extends Serializable

    Permalink

    Provides a set of operations for creating Form values.

  2. object FormError extends Serializable

    Permalink
  3. object Forms

    Permalink

    Contains data manipulation helpers (typically HTTP form handling)

    Contains data manipulation helpers (typically HTTP form handling)

    import play.api.data._
    import play.api.data.Forms._
    
    val taskForm = Form(
      of(Task.apply _, Task.unapply _)(
        "name" -> text(minLength = 3),
        "dueDate" -> date("yyyy-MM-dd"),
        "done" -> boolean
      )
    )
  4. object RepeatedMapping extends Serializable

    Permalink

    Provides a set of operations related to RepeatedMapping values.

  5. package format

    Permalink

    Contains the Format API used by Form.

    Contains the Format API used by Form.

    For example, to define a custom formatter:

    val signedIntFormat = new Formatter[Int] {
    
      def bind(key: String, data: Map[String, String]) = {
        stringFormat.bind(key, data).right.flatMap { value =>
          scala.util.control.Exception.allCatch[Int]
            .either(java.lang.Integer.parseInt(value))
            .left.map(e => Seq(FormError(key, "error.signedNumber", Nil)))
        }
      }
    
      def unbind(key: String, value: Long) = Map(
        key -> ((if (value<0) "-" else "+") + value)
      )
    }
  6. package validation

    Permalink

    Contains the validation API used by Form.

    Contains the validation API used by Form.

    For example, to define a custom constraint:

    val negative = Constraint[Int] {
      case i if i < 0 => Valid
      case _ => Invalid("Must be a negative number.")
    }

Inherited from AnyRef

Inherited from Any

Ungrouped