From d9df5c3fcffe12aac239b58ccf2fd82c19c3be62 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 3 Jan 2016 23:37:14 +0100 Subject: Validate add payment server side --- src/client/elm/Model/View/LoggedIn/Account.elm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client/elm/Model/View/LoggedIn/Account.elm') 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 -- cgit v1.2.3