blob: 7d852b939485078d3ee38184462a000551d30868 (
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
|
module LoggedIn.Income.Model exposing
( Model
, AddIncome
, init
, initForm
, validation
)
import Date exposing (Date)
import Form exposing (Form)
import Form.Validate as Validate exposing (Validation)
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 [] validation
validation : Validation String AddIncome
validation =
Validate.map2 AddIncome
(Validate.field "amount" (Validate.int |> Validate.andThen (Validate.minInt 1)))
(Validate.field "date" Validation.date)
|