mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Add Field.map helper.
This commit is contained in:
parent
0275c296d3
commit
cdf58c62e0
@ -3,7 +3,7 @@ module Pages.Field exposing
|
||||
, select, range, OutsideRange(..)
|
||||
, date, time, TimeOfDay
|
||||
, Field(..), FieldInfo, exactValue
|
||||
, required, withClientValidation, withInitialValue
|
||||
, required, withClientValidation, withInitialValue, map
|
||||
, email, password, search, telephone, url, textarea
|
||||
, withMax, withMin, withStep, withMinLength, withMaxLength
|
||||
, withServerValidation
|
||||
@ -35,7 +35,7 @@ module Pages.Field exposing
|
||||
|
||||
## Field Configuration
|
||||
|
||||
@docs required, withClientValidation, withInitialValue
|
||||
@docs required, withClientValidation, withInitialValue, map
|
||||
|
||||
|
||||
## Text Field Display Options
|
||||
@ -580,6 +580,14 @@ range info field =
|
||||
|> (\(Field innerField _) -> Field { innerField | initialValue = Just (info.initial >> Form.Value.toString) } (FieldRenderer.Input FieldRenderer.Range))
|
||||
|
||||
|
||||
{-| -}
|
||||
map : (parsed -> mapped) -> Field error parsed data kind constraints -> Field error mapped data kind { constraints | wasMapped : Yes }
|
||||
map mapFn field_ =
|
||||
withClientValidation
|
||||
(\value -> ( Just (mapFn value), [] ))
|
||||
field_
|
||||
|
||||
|
||||
{-| -}
|
||||
withClientValidation : (parsed -> ( Maybe mapped, List error )) -> Field error parsed data kind constraints -> Field error mapped data kind { constraints | wasMapped : Yes }
|
||||
withClientValidation mapFn (Field field kind) =
|
||||
|
Loading…
Reference in New Issue
Block a user