aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Income/Model.elm
blob: d6e5e7a306cb145d2ebec91eea3f71f32ff0cf0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module LoggedIn.Income.Model exposing
  ( Model
  , AddIncome
  , init
  , initForm
  )

import Date exposing (Date)

import Form exposing (Form)
import Form.Validate as Validate exposing (..)
import Validation

type alias Model =
  { addIncome : Form String AddIncome
  , test : Bool
  }

type alias AddIncome =
  { amount : Int
  , date : Date
  }

init : Model
init =
  { addIncome = initForm
  , test = False
  }

initForm : Form String AddIncome
initForm = Form.initial [] validate

validate : Validation String AddIncome
validate =
  form2 AddIncome
    (get "amount" (int `andThen` (minInt 1)))
    (get "date" Validation.date)