aboutsummaryrefslogtreecommitdiff
path: root/server/src/Validation/Atomic.hs
diff options
context:
space:
mode:
authorJoris2018-10-28 17:57:58 +0100
committerJoris2018-10-28 17:57:58 +0100
commit40b4994797a797b1fa86cafda789a5c488730c6d (patch)
treead195b31fa442821b9de8f99364e254f0f41935f /server/src/Validation/Atomic.hs
parentdf83b634006c699cfa1e921bf74ce951a906a62f (diff)
downloadbudget-40b4994797a797b1fa86cafda789a5c488730c6d.tar.gz
budget-40b4994797a797b1fa86cafda789a5c488730c6d.tar.bz2
budget-40b4994797a797b1fa86cafda789a5c488730c6d.zip
Delete payment
Diffstat (limited to 'server/src/Validation/Atomic.hs')
-rw-r--r--server/src/Validation/Atomic.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/src/Validation/Atomic.hs b/server/src/Validation/Atomic.hs
new file mode 100644
index 0000000..d15ad49
--- /dev/null
+++ b/server/src/Validation/Atomic.hs
@@ -0,0 +1,32 @@
+module Validation.Atomic
+ ( nonEmpty
+ , nonNullNumber
+ -- , number
+ ) where
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+import qualified Common.Msg as Msg
+
+nonEmpty :: Text -> Maybe Text
+nonEmpty str =
+ if T.null str
+ then Just $ Msg.get Msg.Form_NonEmpty
+ else Nothing
+
+nonNullNumber :: Int -> Maybe Text
+nonNullNumber n =
+ if n == 0
+ then Just $ Msg.get Msg.Form_NonNullNumber
+ else Nothing
+
+-- number :: (Int -> Bool) -> Text -> Maybe Int
+-- number numberForm str =
+-- case reads (T.unpack str) :: [(Int, String)] of
+-- (num, _) : _ ->
+-- if numberForm num
+-- then Just num
+-- else Nothing
+-- _ ->
+-- Nothing