Can't you just create a smaller component that does the validation on
itself, and then compose several of them into a list/dictionary?
componentUpdate : (String -> Bool) -> Msg -> String
componentUpdate hasError msg oldString =
case UserEntersSomething newString
if hasError newString then
oldString
else
newString
fields : Dict String (String -> Bool)
fields = Dict.fromList
[("minutes", validateMinutes)
...
]
mainUpdate msg model =
case ChildComponentMsg childName childMsg ->
Maybe.withDefault model <|
Maybe.map2
(\validationFunction childState -> { model | childStates =
Dict.insert childName (updateChild validationFunction childMsg childState) }
(Dict.get childName fields)
(Dict.get childName model.childStates)
(Maybe pick a better way to write it, but the gist is: use the Elm
Architecture pattern)
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.