diff options
author | Joris | 2016-06-25 15:10:03 +0200 |
---|---|---|
committer | Joris | 2016-06-25 22:09:04 +0200 |
commit | 70720548c9af024dbb6080638ac8e5470c2213eb (patch) | |
tree | a149bd6d8f1448de11ac4b0b41c52bc82052035a /src/server/Validation.hs | |
parent | 4ce4de89a5400b0d8b9cddaa2922901a081fdaaa (diff) | |
download | budget-70720548c9af024dbb6080638ac8e5470c2213eb.tar.gz budget-70720548c9af024dbb6080638ac8e5470c2213eb.tar.bz2 budget-70720548c9af024dbb6080638ac8e5470c2213eb.zip |
Use the search to view either punctual or monthly payments
Diffstat (limited to 'src/server/Validation.hs')
-rw-r--r-- | src/server/Validation.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server/Validation.hs b/src/server/Validation.hs index 455ae5b..1f332c9 100644 --- a/src/server/Validation.hs +++ b/src/server/Validation.hs @@ -6,18 +6,18 @@ module Validation import Data.Text (Text) import qualified Data.Text as T -nonEmpty :: a -> Text -> Either a Text -nonEmpty x str = +nonEmpty :: Text -> Maybe Text +nonEmpty str = if T.null str - then Left x - else Right str + then Nothing + else Just str -number :: x -> (Int -> Bool) -> Text -> Either x Int -number x numberForm str = +number :: (Int -> Bool) -> Text -> Maybe Int +number numberForm str = case reads (T.unpack str) :: [(Int, String)] of (num, _) : _ -> if numberForm num - then Right num - else Left x + then Just num + else Nothing _ -> - Left x + Nothing |