Rename types.

This commit is contained in:
Dillon Kearns 2022-07-24 20:20:05 +02:00
parent ea22871b65
commit 6757b27ea4
16 changed files with 87 additions and 87 deletions

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Form.Value
import Head
import Head.Seo as Seo

View File

@ -6,7 +6,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Head
import Head.Seo as Seo
import Html exposing (Html)
@ -136,7 +136,7 @@ form =
fieldView :
Form.Context String data
-> String
-> OnlyValidation String parsed Form.FieldView.Input
-> Validation String parsed Form.FieldView.Input
-> Html msg
fieldView formState label field =
Html.div []
@ -148,7 +148,7 @@ fieldView formState label field =
]
errorsForField : Form.Context String data -> OnlyValidation String parsed kind -> Html msg
errorsForField : Form.Context String data -> Validation String parsed kind -> Html msg
errorsForField formState field =
(if True then
formState.errors

View File

@ -7,7 +7,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Form.Value
import Head
import Head.Seo as Seo
@ -126,7 +126,7 @@ init maybePageUrl sharedModel static =
fieldView :
Form.Context String data
-> String
-> OnlyValidation String parsed Form.FieldView.Input
-> Validation String parsed Form.FieldView.Input
-> Html msg
fieldView formState label field =
Html.div []
@ -138,7 +138,7 @@ fieldView formState label field =
]
errorsForField : Form.Context String data -> OnlyValidation String parsed kind -> Html msg
errorsForField : Form.Context String data -> Validation String parsed kind -> Html msg
errorsForField formState field =
(if True then
formState.errors

View File

@ -11,7 +11,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Form.Value
import Head
import Head.Seo as Seo
@ -831,7 +831,7 @@ textInput info labelText field =
]
errorsView : Form.Context String data -> OnlyValidation String parsed kind -> Html msg
errorsView : Form.Context String data -> Validation String parsed kind -> Html msg
errorsView formState field =
let
showErrors : Bool

View File

@ -13,7 +13,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Form.Value
import FormDecoder exposing (FormData)
import Graphql.Operation exposing (RootMutation, RootQuery)
@ -230,7 +230,7 @@ createForm =
descriptionFieldView :
Form.Context String data
-> OnlyValidation String parsed Form.FieldView.Input
-> Validation String parsed Form.FieldView.Input
-> Html msg
descriptionFieldView formState field =
Html.div []
@ -242,7 +242,7 @@ descriptionFieldView formState field =
]
errorsForField : Form.Context String data -> OnlyValidation String parsed kind -> Html msg
errorsForField : Form.Context String data -> Validation String parsed kind -> Html msg
errorsForField formState field =
(if True then
formState.errors

View File

@ -7,7 +7,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (FieldValidation, OnlyValidation)
import Form.Validation as Validation exposing (FieldValidation, Validation)
import GroupName exposing (GroupName)
import Head
import Html exposing (Html)

View File

@ -6,7 +6,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (FieldValidation, OnlyValidation)
import Form.Validation as Validation exposing (FieldValidation, Validation)
import Head
import Html exposing (Html)
import Html.Attributes as Attr

View File

@ -6,7 +6,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (FieldValidation, OnlyValidation)
import Form.Validation as Validation exposing (FieldValidation, Validation)
import Head
import Head.Seo as Seo
import Html exposing (Html)

View File

@ -7,7 +7,7 @@ import ErrorPage exposing (ErrorPage)
import Form
import Form.Field as Field
import Form.FieldView
import Form.Validation as Validation exposing (FieldValidation, OnlyValidation)
import Form.Validation as Validation exposing (FieldValidation, Validation)
import Head
import Html exposing (Html)
import Html.Attributes as Attr

View File

@ -80,7 +80,7 @@ import Dict exposing (Dict)
import Dict.Extra
import Form.Field as Field exposing (Field(..))
import Form.FieldView
import Form.Validation as Validation exposing (FieldValidation, LowLevelValidation, OnlyValidation)
import Form.Validation as Validation exposing (AnyValidation, FieldValidation, Validation)
import Html exposing (Html)
import Html.Attributes as Attr
import Html.Lazy
@ -89,7 +89,7 @@ import Html.Styled.Attributes as StyledAttr
import Html.Styled.Lazy
import Json.Encode as Encode
import Pages.FormState as Form exposing (FormState)
import Pages.Internal.Form exposing (Validation(..))
import Pages.Internal.Form exposing (AnyValidation(..))
import Pages.Msg
import Pages.Transition
@ -146,7 +146,7 @@ dynamic :
->
Form
error
{ combine : LowLevelValidation error parsed named constraints1
{ combine : AnyValidation error parsed named constraints1
, view : subView
}
data
@ -155,7 +155,7 @@ dynamic :
Form
error
--((decider -> Validation error parsed named) -> combined)
({ combine : decider -> LowLevelValidation error parsed named constraints1
({ combine : decider -> AnyValidation error parsed named constraints1
, view : decider -> subView
}
-> parsedAndView
@ -174,7 +174,7 @@ dynamic forms formBuilder =
decider
->
{ result : Dict String (List error)
, parsedAndView : { combine : LowLevelValidation error parsed named constraints1, view : subView }
, parsedAndView : { combine : AnyValidation error parsed named constraints1, view : subView }
, serverValidations : DataSource (List ( String, List error ))
}
toParser decider =
@ -192,7 +192,7 @@ dynamic forms formBuilder =
let
newThing :
{ result : Dict String (List error)
, parsedAndView : { combine : decider -> LowLevelValidation error parsed named constraints1, view : decider -> subView } -> parsedAndView
, parsedAndView : { combine : decider -> AnyValidation error parsed named constraints1, view : decider -> subView } -> parsedAndView
, serverValidations : DataSource (List ( String, List error ))
}
newThing =
@ -200,7 +200,7 @@ dynamic forms formBuilder =
FormNew _ parseFn _ ->
parseFn maybeData formState
arg : { combine : decider -> LowLevelValidation error parsed named constraints1, view : decider -> subView }
arg : { combine : decider -> AnyValidation error parsed named constraints1, view : decider -> subView }
arg =
{ combine =
toParser
@ -578,8 +578,8 @@ type alias AppContext app =
mergeResults :
{ a | result : ( LowLevelValidation error parsed named constraints1, Dict String (List error) ) }
-> LowLevelValidation error parsed unnamed constraints2
{ a | result : ( AnyValidation error parsed named constraints1, Dict String (List error) ) }
-> AnyValidation error parsed unnamed constraints2
mergeResults parsed =
case parsed.result of
( Pages.Internal.Form.Validation viewField name ( parsedThing, combineErrors ), individualFieldErrors ) ->
@ -592,7 +592,7 @@ mergeResults parsed =
mergeResultsDataSource :
{ a
| result : ( LowLevelValidation error parsed named constraints, FieldErrors error )
| result : ( AnyValidation error parsed named constraints, FieldErrors error )
, serverValidations : DataSource (List ( String, List error ))
}
-> ( Maybe parsed, DataSource (FieldErrors error) )
@ -668,7 +668,7 @@ parse :
String
-> AppContext app
-> data
-> Form error { info | combine : LowLevelValidation error parsed named constraints } data
-> Form error { info | combine : AnyValidation error parsed named constraints } data
-> ( Maybe parsed, FieldErrors error )
parse formId app data (FormNew _ parser _) =
-- TODO Get transition context from `app` so you can check if the current form is being submitted
@ -676,7 +676,7 @@ parse formId app data (FormNew _ parser _) =
let
parsed :
{ result : Dict String (List error)
, parsedAndView : { info | combine : LowLevelValidation error parsed named constraints }
, parsedAndView : { info | combine : AnyValidation error parsed named constraints }
, serverValidations : DataSource (List ( String, List error ))
}
parsed =
@ -708,13 +708,13 @@ insertIfNonempty key values dict =
{-| -}
runServerSide :
List ( String, String )
-> Form error { all | combine : LowLevelValidation error parsed kind constraints } data
-> Form error { all | combine : AnyValidation error parsed kind constraints } data
-> ( Maybe parsed, DataSource (FieldErrors error) )
runServerSide rawFormData (FormNew _ parser _) =
let
parsed :
{ result : Dict String (List error)
, parsedAndView : { all | combine : LowLevelValidation error parsed kind constraints }
, parsedAndView : { all | combine : AnyValidation error parsed kind constraints }
, serverValidations : DataSource (List ( String, List error ))
}
parsed =
@ -745,13 +745,13 @@ runServerSide rawFormData (FormNew _ parser _) =
{-| -}
runServerSideWithoutServerValidations :
List ( String, String )
-> Form error { all | combine : LowLevelValidation error parsed kind constraints } data
-> Form error { all | combine : AnyValidation error parsed kind constraints } data
-> ( Maybe parsed, FieldErrors error )
runServerSideWithoutServerValidations rawFormData (FormNew _ parser _) =
let
parsed :
{ result : Dict String (List error)
, parsedAndView : { all | combine : LowLevelValidation error parsed kind constraints }
, parsedAndView : { all | combine : AnyValidation error parsed kind constraints }
, serverValidations : DataSource (List ( String, List error ))
}
parsed =
@ -780,7 +780,7 @@ runServerSideWithoutServerValidations rawFormData (FormNew _ parser _) =
|> unwrapValidation
unwrapValidation : LowLevelValidation error parsed named constraints -> ( Maybe parsed, FieldErrors error )
unwrapValidation : AnyValidation error parsed named constraints -> ( Maybe parsed, FieldErrors error )
unwrapValidation (Pages.Internal.Form.Validation viewField name ( maybeParsed, errors )) =
( maybeParsed, errors )
@ -792,7 +792,7 @@ runOneOfServerSide :
List
(Form
error
{ all | combine : LowLevelValidation error parsed kind constraints }
{ all | combine : AnyValidation error parsed kind constraints }
data
)
-> ( Maybe parsed, FieldErrors error )
@ -829,7 +829,7 @@ runOneOfServerSideWithServerValidations :
List
(Form
error
{ all | combine : LowLevelValidation error parsed kind constraints }
{ all | combine : AnyValidation error parsed kind constraints }
data
)
-> ( Maybe parsed, DataSource (FieldErrors error) )
@ -867,7 +867,7 @@ renderHtml :
->
FinalForm
error
(LowLevelValidation error parsed named constraints)
(AnyValidation error parsed named constraints)
data
(Context error data
-> List (Html (Pages.Msg.Msg msg))
@ -917,14 +917,14 @@ toDynamicFetcher :
->
Form
error
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
data
->
FinalForm
error
(LowLevelValidation error parsed field constraints)
(AnyValidation error parsed field constraints)
data
(Context error data -> view)
toDynamicFetcher name (FormNew a b c) =
@ -941,7 +941,7 @@ toDynamicFetcher name (FormNew a b c) =
->
{ result : Dict String (List error)
, parsedAndView :
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
, serverValidations : DataSource (List ( String, List error ))
@ -952,7 +952,7 @@ toDynamicFetcher name (FormNew a b c) =
-> Form.FormState
->
{ result :
( LowLevelValidation error parsed field constraints
( AnyValidation error parsed field constraints
, Dict String (List error)
)
, view : Context error data -> view
@ -965,7 +965,7 @@ toDynamicFetcher name (FormNew a b c) =
foo :
{ result : Dict String (List error)
, parsedAndView :
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
, serverValidations : DataSource (List ( String, List error ))
@ -987,14 +987,14 @@ toDynamicTransition :
->
Form
error
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
data
->
FinalForm
error
(LowLevelValidation error parsed field constraints)
(AnyValidation error parsed field constraints)
data
(Context error data -> view)
toDynamicTransition name (FormNew a b c) =
@ -1011,7 +1011,7 @@ toDynamicTransition name (FormNew a b c) =
->
{ result : Dict String (List error)
, parsedAndView :
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
, serverValidations : DataSource (List ( String, List error ))
@ -1022,7 +1022,7 @@ toDynamicTransition name (FormNew a b c) =
-> Form.FormState
->
{ result :
( LowLevelValidation error parsed field constraints
( AnyValidation error parsed field constraints
, Dict String (List error)
)
, view : Context error data -> view
@ -1035,7 +1035,7 @@ toDynamicTransition name (FormNew a b c) =
foo :
{ result : Dict String (List error)
, parsedAndView :
{ combine : LowLevelValidation error parsed field constraints
{ combine : AnyValidation error parsed field constraints
, view : Context error data -> view
}
, serverValidations : DataSource (List ( String, List error ))
@ -1070,7 +1070,7 @@ renderStyledHtml :
->
FinalForm
error
(LowLevelValidation error parsed named constraints)
(AnyValidation error parsed named constraints)
data
(Context error data
-> List (Html.Styled.Html (Pages.Msg.Msg msg))
@ -1090,7 +1090,7 @@ renderHelper :
-> RenderOptions
-> AppContext app
-> data
-> FormInternal error (LowLevelValidation error parsed named constraints) data (Context error data -> List (Html (Pages.Msg.Msg msg)))
-> FormInternal error (AnyValidation error parsed named constraints) data (Context error data -> List (Html (Pages.Msg.Msg msg)))
-> Html (Pages.Msg.Msg msg)
renderHelper attrs maybe options formState data ((FormInternal fieldDefinitions parser toInitialValues) as form) =
-- TODO Get transition context from `app` so you can check if the current form is being submitted
@ -1129,7 +1129,7 @@ renderStyledHelper :
-> RenderOptions
-> AppContext app
-> data
-> FormInternal error (LowLevelValidation error parsed named constraints) data (Context error data -> List (Html.Styled.Html (Pages.Msg.Msg msg)))
-> FormInternal error (AnyValidation error parsed named constraints) data (Context error data -> List (Html.Styled.Html (Pages.Msg.Msg msg)))
-> Html.Styled.Html (Pages.Msg.Msg msg)
renderStyledHelper attrs maybe options formState data ((FormInternal fieldDefinitions parser toInitialValues) as form) =
-- TODO Get transition context from `app` so you can check if the current form is being submitted
@ -1171,7 +1171,7 @@ helperValues :
-> AppContext app
-> data
---> Form error parsed data view
-> FormInternal error (LowLevelValidation error parsed named constraints) data (Context error data -> List view)
-> FormInternal error (AnyValidation error parsed named constraints) data (Context error data -> List view)
-> { formId : String, hiddenInputs : List view, children : List view, isValid : Bool }
helperValues toHiddenInput maybe options formState data (FormInternal fieldDefinitions parser toInitialValues) =
let
@ -1210,14 +1210,14 @@ helperValues toHiddenInput maybe options formState data (FormInternal fieldDefin
|> Dict.union part2
parsed :
{ result : ( LowLevelValidation error parsed named constraints, Dict String (List error) )
{ result : ( AnyValidation error parsed named constraints, Dict String (List error) )
, view : Context error data -> List view
, serverValidations : DataSource (List ( String, List error ))
}
parsed =
parser (Just data) thisFormState
merged : LowLevelValidation error parsed named constraints
merged : AnyValidation error parsed named constraints
merged =
mergeResults
{ parsed
@ -1344,7 +1344,7 @@ toResult ( maybeParsed, fieldErrors ) =
type alias HtmlForm error parsed data msg =
Form
error
{ combine : Validation.OnlyValidation error parsed
{ combine : Validation.Validation error parsed
, view : Context error data -> List (Html (Pages.Msg.Msg msg))
}
data
@ -1354,7 +1354,7 @@ type alias HtmlForm error parsed data msg =
type alias StyledHtmlForm error parsed data msg =
Form
error
{ combine : OnlyValidation error parsed
{ combine : Validation error parsed
, view : Context error data -> List (Html.Styled.Html (Pages.Msg.Msg msg))
}
data

View File

@ -26,7 +26,7 @@ import Html.Attributes as Attr
import Html.Styled
import Html.Styled.Attributes as StyledAttr
import Json.Encode as Encode
import Pages.Internal.Form exposing (Validation(..), ViewField)
import Pages.Internal.Form exposing (AnyValidation(..), ViewField)
{-| -}

View File

@ -1,5 +1,5 @@
module Form.Validation exposing
( OnlyValidation, FieldValidation, LowLevelValidation
( Validation, FieldValidation, AnyValidation
, andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, withError, withErrorIf, withFallback
, value, fieldName
)
@ -9,7 +9,7 @@ module Form.Validation exposing
## Validations
@docs OnlyValidation, FieldValidation, LowLevelValidation
@docs Validation, FieldValidation, AnyValidation
@docs andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, withError, withErrorIf, withFallback
@ -21,22 +21,22 @@ module Form.Validation exposing
-}
import Dict exposing (Dict)
import Pages.Internal.Form exposing (Validation(..))
import Pages.Internal.Form exposing (AnyValidation(..))
{-| -}
type alias OnlyValidation error parsed =
Pages.Internal.Form.Validation error parsed Never Never
type alias Validation error parsed =
Pages.Internal.Form.AnyValidation error parsed Never Never
{-| -}
type alias FieldValidation error parsed kind =
Pages.Internal.Form.Validation error parsed kind { field : kind }
Pages.Internal.Form.AnyValidation error parsed kind { field : kind }
{-| -}
type alias LowLevelValidation error parsed kind constraints =
Pages.Internal.Form.Validation error parsed kind constraints
type alias AnyValidation error parsed kind constraints =
Pages.Internal.Form.AnyValidation error parsed kind constraints
{-| -}
@ -47,13 +47,13 @@ fieldName (Validation viewField name ( maybeParsed, errors )) =
{-| -}
succeed : parsed -> OnlyValidation error parsed
succeed : parsed -> Validation error parsed
succeed parsed =
Validation Nothing Nothing ( Just parsed, Dict.empty )
{-| -}
withFallback : parsed -> LowLevelValidation error parsed named constraints -> LowLevelValidation error parsed named constraints
withFallback : parsed -> AnyValidation error parsed named constraints -> AnyValidation error parsed named constraints
withFallback parsed (Validation viewField name ( maybeParsed, errors )) =
Validation viewField
name
@ -65,33 +65,33 @@ withFallback parsed (Validation viewField name ( maybeParsed, errors )) =
{-| -}
value : LowLevelValidation error parsed named constraint -> Maybe parsed
value : AnyValidation error parsed named constraint -> Maybe parsed
value (Validation _ _ ( maybeParsed, _ )) =
maybeParsed
{-| -}
parseWithError : parsed -> ( String, error ) -> OnlyValidation error parsed
parseWithError : parsed -> ( String, error ) -> Validation error parsed
parseWithError parsed ( key, error ) =
Validation Nothing Nothing ( Just parsed, Dict.singleton key [ error ] )
{-| -}
fail : FieldValidation error parsed1 field -> error -> OnlyValidation error parsed
fail : FieldValidation error parsed1 field -> error -> Validation error parsed
fail (Validation _ key _) parsed =
-- TODO need to prevent Never fields from being used
Validation Nothing Nothing ( Nothing, Dict.singleton (key |> Maybe.withDefault "") [ parsed ] )
{-| -}
withError : FieldValidation error parsed1 field -> error -> LowLevelValidation error parsed2 named constraints -> LowLevelValidation error parsed2 named constraints
withError : FieldValidation error parsed1 field -> error -> AnyValidation error parsed2 named constraints -> AnyValidation error parsed2 named constraints
withError (Validation _ key _) error (Validation viewField name ( maybeParsedA, errorsA )) =
-- TODO need to prevent Never fields from being used
Validation viewField name ( maybeParsedA, errorsA |> insertIfNonempty (key |> Maybe.withDefault "") [ error ] )
{-| -}
withErrorIf : Bool -> FieldValidation error ignored field -> error -> LowLevelValidation error parsed named constraints -> LowLevelValidation error parsed named constraints
withErrorIf : Bool -> FieldValidation error ignored field -> error -> AnyValidation error parsed named constraints -> AnyValidation error parsed named constraints
withErrorIf includeError (Validation _ key _) error (Validation viewField name ( maybeParsedA, errorsA )) =
-- TODO use something like { field : kind } for type variable to check that it represents a field
Validation viewField
@ -110,13 +110,13 @@ withErrorIf includeError (Validation _ key _) error (Validation viewField name (
{-| -}
map : (parsed -> mapped) -> LowLevelValidation error parsed named constraint -> OnlyValidation error mapped
map : (parsed -> mapped) -> AnyValidation error parsed named constraint -> Validation error mapped
map mapFn (Validation viewField name ( maybeParsedA, errorsA )) =
Validation Nothing name ( Maybe.map mapFn maybeParsedA, errorsA )
{-| -}
fromResult : Result ( String, error ) parsed -> OnlyValidation error parsed
fromResult : Result ( String, error ) parsed -> Validation error parsed
fromResult result =
case result of
Ok parsed ->
@ -127,13 +127,13 @@ fromResult result =
{-| -}
andMap : LowLevelValidation error a named1 constraints1 -> LowLevelValidation error (a -> b) named2 constraints2 -> OnlyValidation error b
andMap : AnyValidation error a named1 constraints1 -> AnyValidation error (a -> b) named2 constraints2 -> Validation error b
andMap =
map2 (|>)
{-| -}
andThen : (parsed -> LowLevelValidation error mapped named1 constraints1) -> LowLevelValidation error parsed named2 constraints2 -> OnlyValidation error mapped
andThen : (parsed -> AnyValidation error mapped named1 constraints1) -> AnyValidation error parsed named2 constraints2 -> Validation error mapped
andThen andThenFn (Validation _ name ( maybeParsed, errors )) =
case maybeParsed of
Just parsed ->
@ -147,7 +147,7 @@ andThen andThenFn (Validation _ name ( maybeParsed, errors )) =
{-| -}
map2 : (a -> b -> c) -> LowLevelValidation error a named1 constraints1 -> LowLevelValidation error b named2 constraints2 -> OnlyValidation error c
map2 : (a -> b -> c) -> AnyValidation error a named1 constraints1 -> AnyValidation error b named2 constraints2 -> Validation error c
map2 f (Validation _ name1 ( maybeParsedA, errorsA )) (Validation _ name2 ( maybeParsedB, errorsB )) =
Validation Nothing
Nothing
@ -157,7 +157,7 @@ map2 f (Validation _ name1 ( maybeParsedA, errorsA )) (Validation _ name2 ( mayb
{-| -}
fromMaybe : Maybe parsed -> OnlyValidation error parsed
fromMaybe : Maybe parsed -> Validation error parsed
fromMaybe maybe =
Validation Nothing Nothing ( maybe, Dict.empty )

View File

@ -1,11 +1,11 @@
module Pages.Internal.Form exposing (Validation(..), ViewField)
module Pages.Internal.Form exposing (AnyValidation(..), ViewField)
import Dict exposing (Dict)
import Json.Encode as Encode
import Pages.FormState
type Validation error parsed kind field
type AnyValidation error parsed kind field
= Validation (Maybe (ViewField kind)) (Maybe String) ( Maybe parsed, Dict String (List error) )

View File

@ -90,7 +90,7 @@ import CookieParser
import DataSource exposing (DataSource)
import Dict exposing (Dict)
import Form
import Form.Validation as Validation exposing (LowLevelValidation, OnlyValidation)
import Form.Validation as Validation exposing (AnyValidation, Validation)
import FormData
import Internal.Request
import Json.Decode
@ -887,7 +887,7 @@ formDataWithoutServerValidation :
List
(Form.Form
error
{ all | combine : LowLevelValidation error combined kind constraints }
{ all | combine : AnyValidation error combined kind constraints }
data
)
-> Parser (Result { fields : List ( String, String ), errors : Dict String (List error) } combined)
@ -923,7 +923,7 @@ formData :
List
(Form.Form
error
{ all | combine : LowLevelValidation error combined kind constraints }
{ all | combine : AnyValidation error combined kind constraints }
data
)
-> Parser (DataSource (Result { fields : List ( String, String ), errors : Dict String (List error) } combined))

View File

@ -5,7 +5,7 @@ import Dict
import Expect
import Form exposing (Form)
import Form.Field as Field
import Form.Validation as Validation exposing (OnlyValidation)
import Form.Validation as Validation exposing (Validation)
import Test exposing (Test, describe, test)
@ -167,7 +167,7 @@ all =
checkinFormParser :
Form
String
{ combine : OnlyValidation String ( Date, Date ) Never, view : a -> MyView }
{ combine : Validation String ( Date, Date ) Never, view : a -> MyView }
data
checkinFormParser =
Form.init
@ -272,7 +272,7 @@ all =
]
, describe "dependent parsing" <|
let
linkForm : Form String { combine : OnlyValidation String PostAction Never, view : Form.Context String data -> MyView } data
linkForm : Form String { combine : Validation String PostAction Never, view : Form.Context String data -> MyView } data
linkForm =
Form.init
(\url ->
@ -289,7 +289,7 @@ all =
|> Field.url
)
postForm : Form String { combine : OnlyValidation String PostAction Never, view : Form.Context String data -> MyView } data
postForm : Form String { combine : Validation String PostAction Never, view : Form.Context String data -> MyView } data
postForm =
Form.init
(\title body ->
@ -309,7 +309,7 @@ all =
|> Form.field "title" (Field.text |> Field.required "Required")
|> Form.field "body" Field.text
dependentParser : Form String { combine : OnlyValidation String PostAction Never, view : Form.Context String data -> MyView } data
dependentParser : Form String { combine : Validation String PostAction Never, view : Form.Context String data -> MyView } data
dependentParser =
Form.init
(\kind postForm_ ->