diff options
Diffstat (limited to 'src/client/elm/LoggedIn/Income/Model.elm')
-rw-r--r-- | src/client/elm/LoggedIn/Income/Model.elm | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/client/elm/LoggedIn/Income/Model.elm b/src/client/elm/LoggedIn/Income/Model.elm index e56e290..d6e5e7a 100644 --- a/src/client/elm/LoggedIn/Income/Model.elm +++ b/src/client/elm/LoggedIn/Income/Model.elm @@ -5,14 +5,11 @@ module LoggedIn.Income.Model exposing , initForm ) -import String exposing (toInt, split) -import Date -import Time exposing (Time) -import Date.Extra.Create exposing (dateFromFields) -import Date.Extra.Core exposing (intToMonth) +import Date exposing (Date) import Form exposing (Form) import Form.Validate as Validate exposing (..) +import Validation type alias Model = { addIncome : Form String AddIncome @@ -20,8 +17,8 @@ type alias Model = } type alias AddIncome = - { time : Time - , amount : Int + { amount : Int + , date : Date } init : Model @@ -36,17 +33,5 @@ initForm = Form.initial [] validate validate : Validation String AddIncome validate = form2 AddIncome - (get "creation" timeValidation) (get "amount" (int `andThen` (minInt 1))) - -timeValidation : Validation String Time -timeValidation = - customValidation string (\str -> - case split "/" str of - [day, month, year] -> - case (toInt day, toInt month, toInt year) of - (Ok dayNum, Ok monthNum, Ok yearNum) -> - Ok (Date.toTime (dateFromFields yearNum (intToMonth monthNum) dayNum 0 0 0 0)) - _ -> Err (customError "InvalidDate") - _ -> Err (customError "InvalidDate") - ) + (get "date" Validation.date) |