Looks about right to me, although I might be tempted to switch the order of 
the first two arguments in checkAll - you can then use it as a function 
which takes a list of model -> Bool functions and returns a new model -> 
Bool function (a sort of predicate combinator).

On Tuesday, 4 October 2016 02:10:14 UTC+11, Rupert Smith wrote:
>
> Hi,
>
> I need to put some validation checks on a form, things like
>
> if not (model.password1 == model.password2) then
>     Textfield.error <| "Passwords do not match."
>
> but I will also need to re-use those checks to enable/disable the submit 
> button.
>
> So I am thinking pull them out into functions:
>
> checkSomething : model -> Bool
>
> and then have some helper function that lets me combine many checks over 
> the model to a Bool
>
> checkAll : model -> List (model -> Bool) -> Bool
>
> Sound right?
>

-- 
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.

Reply via email to