module Model.View.Payment.Add ( AddPayment , initAddPayment , validateName , validateCost ) where import Result as Result exposing (Result(..)) import Utils.Validation exposing (..) type alias AddPayment = { name : String , nameError : Maybe String , cost : String , costError : Maybe String } initAddPayment : AddPayment initAddPayment = { name = "" , nameError = Nothing , cost = "" , costError = Nothing } validateName : String -> Result String String validateName name = name |> validateNonEmpty "The category is required." validateCost : String -> Result String Int validateCost cost = cost |> validateNonEmpty "The cost is required." |> flip Result.andThen (validateNumber "The cost must be a number.")