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