mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Add a field map function.
This commit is contained in:
parent
c7dbf796b1
commit
ad22e15393
10
src/Form.elm
10
src/Form.elm
@ -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) =
|
||||
|
Loading…
Reference in New Issue
Block a user