Add Validation.value helper to get maybe parsed value.

This commit is contained in:
Dillon Kearns 2022-07-09 08:49:44 -07:00
parent 1a588ed576
commit 4771b9f476
2 changed files with 13 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,14 @@
module Form.Validation exposing (Validation, andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, withError, withErrorIf, withFallback)
module Form.Validation exposing
( Validation, andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, withError, withErrorIf, withFallback
, value
)
{-|
@docs Validation, andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, withError, withErrorIf, withFallback
@docs value
-}
import Dict exposing (Dict)
@ -33,6 +38,12 @@ withFallback parsed (Validation name ( maybeParsed, errors )) =
)
{-| -}
value : Validation error parsed named -> Maybe parsed
value (Validation _ ( maybeParsed, _ )) =
maybeParsed
{-| -}
parseWithError : parsed -> ( String, error ) -> Validation error parsed Never
parseWithError parsed ( key, error ) =