diff options
author | Joris | 2017-03-24 09:21:06 +0000 |
---|---|---|
committer | Joris | 2017-03-24 09:21:06 +0000 |
commit | c0ac16a713c4e53cf6af8e72a6d5f6b8ac5d6456 (patch) | |
tree | 8a438430cee7411259fc395d8f3898488e85d750 /src/client/elm/Dialog/AddIncome/Model.elm | |
parent | 293eb8295162bf0a038f488237db9c9d1316c04d (diff) | |
parent | cfca18262c1ff48dcb683ddab7d03cf8e55573ff (diff) |
Merge branch 'features/categories' into 'master'
Features/categories
See merge request !1
Diffstat (limited to 'src/client/elm/Dialog/AddIncome/Model.elm')
-rw-r--r-- | src/client/elm/Dialog/AddIncome/Model.elm | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/client/elm/Dialog/AddIncome/Model.elm b/src/client/elm/Dialog/AddIncome/Model.elm index 0d52b22..ad7b25a 100644 --- a/src/client/elm/Dialog/AddIncome/Model.elm +++ b/src/client/elm/Dialog/AddIncome/Model.elm @@ -4,6 +4,7 @@ module Dialog.AddIncome.Model exposing , initialAdd , initialClone , initialEdit + , validation ) import Date exposing (Date) @@ -24,29 +25,29 @@ type alias Model = } init : Form String Model -init = Form.initial [] validate +init = Form.initial [] validation initialAdd : Translations -> Date -> List (String, Field) initialAdd translations date = - [ ("date", Field.Text (Date.shortView date translations)) + [ ("date", Field.string (Date.shortView date translations)) ] initialClone : Translations -> Date -> Income -> List (String, Field) initialClone translations date income = - [ ("amount", Field.Text (toString income.amount)) - , ("date", Field.Text (Date.shortView date translations)) + [ ("amount", Field.string (toString income.amount)) + , ("date", Field.string (Date.shortView date translations)) ] initialEdit : Translations -> IncomeId -> Income -> List (String, Field) initialEdit translations incomeId income = - [ ("id", Field.Text (toString incomeId)) - , ("amount", Field.Text (toString income.amount)) - , ("date", Field.Text (Date.shortView (Date.fromTime income.time) translations)) + [ ("id", Field.string (toString incomeId)) + , ("amount", Field.string (toString income.amount)) + , ("date", Field.string (Date.shortView (Date.fromTime income.time) translations)) ] -validate : Validation String Model -validate = - Validate.form3 Model - (Validate.get "id" (Validate.maybe Validate.int)) - (Validate.get "amount" (Validate.int `Validate.andThen` (Validate.minInt 1))) - (Validate.get "date" Validation.date) +validation : Validation String Model +validation = + Validate.map3 Model + (Validate.field "id" (Validate.maybe Validate.int)) + (Validate.field "amount" (Validate.int |> Validate.andThen (Validate.minInt 1))) + (Validate.field "date" Validation.date) |