diff options
author | Joris Guyonvarch | 2015-08-14 17:43:10 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-08-14 17:43:10 +0200 |
commit | 965c0f57875e27fd09df2fc72487f4651addb79b (patch) | |
tree | 3123597112e990fe06405557485e664d3a8da5f3 /src/client/Utils | |
parent | 006d54bf4ac4dd9e05d62d0007759f28740fd77a (diff) |
Cost must not be negative
Diffstat (limited to 'src/client/Utils')
-rw-r--r-- | src/client/Utils/Validation.elm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/Utils/Validation.elm b/src/client/Utils/Validation.elm index 0c1773e..b9bccb3 100644 --- a/src/client/Utils/Validation.elm +++ b/src/client/Utils/Validation.elm @@ -12,10 +12,12 @@ validateNonEmpty message str = then Err message else Ok str -validateNumber : String -> String -> Result String Int -validateNumber message str = +validateNumber : String -> (Int -> Bool) -> String -> Result String Int +validateNumber message numberForm str = case readInt str of Just number -> - Ok number + if numberForm number + then Ok number + else Err message Nothing -> Err message |