diff options
Diffstat (limited to 'src/client/Utils/Validation.elm')
-rw-r--r-- | src/client/Utils/Validation.elm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/client/Utils/Validation.elm b/src/client/Utils/Validation.elm new file mode 100644 index 0000000..0c1773e --- /dev/null +++ b/src/client/Utils/Validation.elm @@ -0,0 +1,21 @@ +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 |