aboutsummaryrefslogtreecommitdiff
path: root/server/src/Validation/Income.hs
blob: 5e034d1a1b5826299489b9659bdbd17eda2f2e5e (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
module Validation.Income
  ( createIncome
  , editIncome
  ) where

import           Data.Text                (Text)
import           Data.Validation          (Validation)
import qualified Data.Validation          as V

import           Common.Model             (CreateIncomeForm (..),
                                           EditIncomeForm (..))
import qualified Common.Validation.Income as IncomeValidation
import           Model.CreateIncome       (CreateIncome (..))
import           Model.EditIncome         (EditIncome (..))

createIncome :: CreateIncomeForm -> Validation Text CreateIncome
createIncome form =
  CreateIncome
    <$> IncomeValidation.amount (_createIncomeForm_amount form)
    <*> IncomeValidation.date (_createIncomeForm_date form)

editIncome :: EditIncomeForm -> Validation Text EditIncome
editIncome form =
  EditIncome
    <$> V.Success (_editIncomeForm_id form)
    <*> IncomeValidation.amount (_editIncomeForm_amount form)
    <*> IncomeValidation.date (_editIncomeForm_date form)