aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Income/Model.elm
blob: cf1bf57883864c603a4adea81058cb32905bb666 (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
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
  }

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

init : Model
init =
  { addIncome = initForm
  }

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)