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
- Alphabetic
- By Inheritance
- WrappedMapping
- Serializable
- Product
- Equals
- Mapping
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new WrappedMapping(wrapped: Mapping[A], f1: (A) => B, f2: (B) => A, additionalConstraints: Seq[Constraint[B]] = Nil)
- 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
- val additionalConstraints: Seq[Constraint[B]]
- def bind(data: Map[String, String]): Either[Seq[FormError], B]
Binds this field, i.e.
Binds this field, i.e. construct a concrete value from submitted data.
- data
the submitted data
- returns
either a concrete value of type
B
or a set of errors, if the binding failed
- Definition Classes
- → Mapping
- val constraints: Seq[Constraint[B]]
The constraints associated with this field.
The constraints associated with this field.
- Definition Classes
- → Mapping
- val f1: (A) => B
- val f2: (B) => A
- 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
- val key: String
The field key.
The field key.
- Definition Classes
- → Mapping
- 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
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def transform[B](f1: (B) => B, f2: (B) => B): 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
- def unbind(value: B): 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
- def unbindAndValidate(value: B): (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
- def verifying(constraints: Constraint[B]*): Mapping[B]
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) )
- constraints
the constraints to add
- returns
the new mapping
- Definition Classes
- → Mapping
- def verifying(error: => String, constraint: (B) => Boolean): Mapping[B]
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
- def verifying(constraint: (B) => Boolean): Mapping[B]
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
- def withPrefix(prefix: String): Mapping[B]
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
- val wrapped: Mapping[A]
A mapping wrapping another existing mapping with transformation functions.
Existing wrapped mapping
Transformation function from A to B
Transformation function from B to A
Additional constraints of type B