FormCodec
trait FormCodec[A]Decodes and validates FormData as a value of type A.
Codecs are reusable descriptions and do not catch exceptions thrown by user functions. zip evaluates both codecs against the same input and accumulates their ordered errors, while map and emap form a dependent chain that stops at the first failed stage.
For example:
val name = FormField.requiredString(FormPath("profile", "name")).codec
val email = FormField.requiredString(FormPath("profile", "email")).codec
val profile = name.zip(email)Type parameters
Athe successfully decoded value
Defined by scalive.FormCodec. View source (scalive/api/src/scalive/forms/FormCodec.scala:19-49)
Methods4
decode
def decode(data: FormData): Either[FormErrors, A]Decodes data, returning all errors produced by this codec.
Defined by scalive.FormCodec.decode. View source (scalive/api/src/scalive/forms/FormCodec.scala:23-23)
emap
def emap[B](f: A => Either[FormErrors, B]): FormCodec[B]Runs an error-producing transformation after successful decoding.
If this codec fails, f is not evaluated and its potential errors cannot be accumulated.
Defined by scalive.FormCodec.emap. View source (scalive/api/src/scalive/forms/FormCodec.scala:33-34)
map
def map[B](f: A => B): FormCodec[B]Transforms a successful value; existing decoding errors short-circuit the function.
Defined by scalive.FormCodec.map. View source (scalive/api/src/scalive/forms/FormCodec.scala:26-27)
zip
def zip[B](that: FormCodec[B]): FormCodec[(A, B)]Decodes both codecs against the same data and returns their pair.
Both sides are evaluated, left before right. If both fail, the left errors are followed by the right errors; if only one fails, that side's errors are returned.
Defined by scalive.FormCodec.zip. View source (scalive/api/src/scalive/forms/FormCodec.scala:41-48)