diff options
author | Joris | 2018-11-01 13:14:25 +0100 |
---|---|---|
committer | Joris | 2019-08-04 21:14:32 +0200 |
commit | 2741f47ef7b87255203bc2f7f7b2b9140c70b8f0 (patch) | |
tree | ea5f685cdf8f3de2efa1113325d45faaa90c977e /common/src/Common/Validation/Payment.hs | |
parent | 86957359ecf54c205aee1c09e151172c327e987a (diff) |
Implementing client side validation
Diffstat (limited to 'common/src/Common/Validation/Payment.hs')
-rw-r--r-- | common/src/Common/Validation/Payment.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/src/Common/Validation/Payment.hs b/common/src/Common/Validation/Payment.hs new file mode 100644 index 0000000..b6c1d30 --- /dev/null +++ b/common/src/Common/Validation/Payment.hs @@ -0,0 +1,21 @@ +module Common.Validation.Payment + ( name + , cost + , date + ) where + +import Data.Text (Text) +import Data.Time.Calendar (Day) +import Data.Validation (Validation) +import qualified Data.Validation as Validation + +import qualified Common.Validation.Atomic as Atomic + +name :: Text -> Validation Text Text +name = Atomic.nonEmpty + +cost :: Text -> Validation Text Int +cost input = Validation.bindValidation (Atomic.number input) Atomic.nonNullNumber + +date :: Text -> Validation Text Day +date = Atomic.day |