aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model/View/LoggedIn/Account.elm
diff options
context:
space:
mode:
authorJoris2016-01-03 23:37:14 +0100
committerJoris2016-01-03 23:46:19 +0100
commitd9df5c3fcffe12aac239b58ccf2fd82c19c3be62 (patch)
treeaee62828e85c9d30e2beb5954062942f0d5d53f4 /src/client/elm/Model/View/LoggedIn/Account.elm
parentd22d10da342520163014dda255d5d9bd5e1a80c0 (diff)
downloadbudget-d9df5c3fcffe12aac239b58ccf2fd82c19c3be62.tar.gz
budget-d9df5c3fcffe12aac239b58ccf2fd82c19c3be62.tar.bz2
budget-d9df5c3fcffe12aac239b58ccf2fd82c19c3be62.zip
Validate add payment server side
Diffstat (limited to 'src/client/elm/Model/View/LoggedIn/Account.elm')
-rw-r--r--src/client/elm/Model/View/LoggedIn/Account.elm12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/client/elm/Model/View/LoggedIn/Account.elm b/src/client/elm/Model/View/LoggedIn/Account.elm
index 4638c8d..d03d84f 100644
--- a/src/client/elm/Model/View/LoggedIn/Account.elm
+++ b/src/client/elm/Model/View/LoggedIn/Account.elm
@@ -9,8 +9,8 @@ module Model.View.LoggedIn.Account
import Result as Result exposing (Result(..))
import Dict
+import String
-import Utils.Validation exposing (..)
import Utils.Dict exposing (mapValues)
import Model.Translations exposing (..)
@@ -62,6 +62,10 @@ initIncomeEdition income =
validateIncome : String -> Translations -> Result String Int
validateIncome amount translations =
- amount
- |> validateNonEmpty (getMessage "IncomeRequired" translations)
- |> flip Result.andThen (validateNumber (getMessage "IncomeMustBePositiveNumber" translations) (\number -> number > 0))
+ case String.toInt amount of
+ Ok number ->
+ if number > 0
+ then Ok number
+ else Err <| getMessage "IncomeMustBePositiveNumber" translations
+ Err _ ->
+ Err <| getMessage "IncomeRequired" translations