module Utils.Validation
  ( validateNonEmpty
  , validateNumber
  ) where

import String
import Reads exposing (readInt)

validateNonEmpty : String -> String -> Result String String
validateNonEmpty message str =
  if String.isEmpty str
   then Err message
   else Ok str

validateNumber : String -> String -> Result String Int
validateNumber message str =
  case readInt str of
    Just number ->
      Ok number
    Nothing ->
      Err message