diff options
author | Joris | 2017-03-24 09:21:04 +0000 |
---|---|---|
committer | Joris | 2017-03-24 09:21:04 +0000 |
commit | cfca18262c1ff48dcb683ddab7d03cf8e55573ff (patch) | |
tree | 8a438430cee7411259fc395d8f3898488e85d750 /src/client/elm/LoggedIn/Category/Model.elm | |
parent | 293eb8295162bf0a038f488237db9c9d1316c04d (diff) | |
download | budget-cfca18262c1ff48dcb683ddab7d03cf8e55573ff.tar.gz budget-cfca18262c1ff48dcb683ddab7d03cf8e55573ff.tar.bz2 budget-cfca18262c1ff48dcb683ddab7d03cf8e55573ff.zip |
Features/categories
Diffstat (limited to 'src/client/elm/LoggedIn/Category/Model.elm')
-rw-r--r-- | src/client/elm/LoggedIn/Category/Model.elm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/client/elm/LoggedIn/Category/Model.elm b/src/client/elm/LoggedIn/Category/Model.elm new file mode 100644 index 0000000..7092fc4 --- /dev/null +++ b/src/client/elm/LoggedIn/Category/Model.elm @@ -0,0 +1,36 @@ +module LoggedIn.Category.Model exposing + ( Model + , AddCategory + , init + , initForm + , validation + ) + +import Date exposing (Date) + +import Form exposing (Form) +import Form.Validate as Validate exposing (Validation) +import Validation + +type alias Model = + { addCategory : Form String AddCategory + } + +type alias AddCategory = + { amount : Int + , date : Date + } + +init : Model +init = + { addCategory = initForm + } + +initForm : Form String AddCategory +initForm = Form.initial [] validation + +validation : Validation String AddCategory +validation = + Validate.map2 AddCategory + (Validate.field "amount" (Validate.int |> Validate.andThen (Validate.minInt 1))) + (Validate.field "date" Validation.date) |