Add a field map function.

This commit is contained in:
Dillon Kearns 2022-04-06 17:01:11 -07:00
parent c7dbf796b1
commit ad22e15393

View File

@ -5,7 +5,7 @@ module Form exposing
, isSubmitting, SubmitStatus(..)
, FieldRenderInfo, FieldStatus(..), isAtLeast
, with, append, appendForm
, Field
, Field, map
, withInitialValue
, checkbox, date, time, email, hidden, multiple, int, float, password, radio, range, telephone, text, url, floatRange, search
, submit
@ -57,7 +57,7 @@ The form submissions are handled internally. Both tracking the submit status, an
## Fields
@docs Field
@docs Field, map
## Initial Values
@ -1467,6 +1467,12 @@ withServerValidation serverValidation (Field field) =
}
{-| -}
map : (value -> mapped) -> Field error value view constraints -> Field error mapped view { constraints | wasMapped : Yes }
map mapFn field =
withClientValidation (mapFn >> Ok) field
{-| -}
withClientValidation : (value -> Result error mapped) -> Field error value view constraints -> Field error mapped view { constraints | wasMapped : Yes }
withClientValidation mapFn (Field field) =