aboutsummaryrefslogtreecommitdiff
path: root/common/src/Common/Validation
diff options
context:
space:
mode:
authorJoris2019-12-08 11:39:37 +0100
committerJoris2019-12-08 11:39:37 +0100
commit316bda10c6bec8b5ccc9e23f1f677c076205f046 (patch)
tree98da1d18834108af50f80ca6fa5c0f4facc42472 /common/src/Common/Validation
parente622e8fdd2e40b4306b5cc724d8dfb76bf976242 (diff)
Add category page
Diffstat (limited to 'common/src/Common/Validation')
-rw-r--r--common/src/Common/Validation/Atomic.hs5
-rw-r--r--common/src/Common/Validation/Category.hs15
2 files changed, 20 insertions, 0 deletions
diff --git a/common/src/Common/Validation/Atomic.hs b/common/src/Common/Validation/Atomic.hs
index 3516668..2a356df 100644
--- a/common/src/Common/Validation/Atomic.hs
+++ b/common/src/Common/Validation/Atomic.hs
@@ -4,6 +4,7 @@ module Common.Validation.Atomic
, number
, nonNullNumber
, day
+ , color
) where
import Data.Text (Text)
@@ -45,3 +46,7 @@ day str =
case Time.parseDay str of
Just d -> V.Success d
Nothing -> V.Failure $ Msg.get Msg.Form_InvalidDate
+
+-- TODO: validate
+color :: Text -> Validation Text Text
+color str = V.Success str
diff --git a/common/src/Common/Validation/Category.hs b/common/src/Common/Validation/Category.hs
new file mode 100644
index 0000000..f9e6ab4
--- /dev/null
+++ b/common/src/Common/Validation/Category.hs
@@ -0,0 +1,15 @@
+module Common.Validation.Category
+ ( name
+ , color
+ ) where
+
+import Data.Text (Text)
+import Data.Validation (Validation)
+
+import qualified Common.Validation.Atomic as Atomic
+
+name :: Text -> Validation Text Text
+name = Atomic.nonEmpty
+
+color :: Text -> Validation Text Text
+color = Atomic.color