blob: 12f21179e0d4bfabea1ef52e45a36d7039836060 (
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.Category
( createCategory
, editCategory
) where
import Data.Text (Text)
import Data.Validation (Validation)
import qualified Data.Validation as V
import Common.Model (CreateCategoryForm (..),
EditCategoryForm (..))
import qualified Common.Validation.Category as CategoryValidation
import Model.CreateCategory (CreateCategory (..))
import Model.EditCategory (EditCategory (..))
createCategory :: CreateCategoryForm -> Validation Text CreateCategory
createCategory form =
CreateCategory
<$> CategoryValidation.name (_createCategoryForm_name form)
<*> CategoryValidation.color (_createCategoryForm_color form)
editCategory :: EditCategoryForm -> Validation Text EditCategory
editCategory form =
EditCategory
<$> V.Success (_editCategoryForm_id form)
<*> CategoryValidation.name (_editCategoryForm_name form)
<*> CategoryValidation.color (_editCategoryForm_color form)
|