From 965c0f57875e27fd09df2fc72487f4651addb79b Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Fri, 14 Aug 2015 17:43:10 +0200 Subject: Cost must not be negative --- src/client/Model/View/Payment/Add.elm | 2 +- src/client/Utils/Validation.elm | 8 +++++--- src/server/Model/Message/Translations.hs | 18 +++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/client/Model/View/Payment/Add.elm b/src/client/Model/View/Payment/Add.elm index 5428c3d..5ab7a40 100644 --- a/src/client/Model/View/Payment/Add.elm +++ b/src/client/Model/View/Payment/Add.elm @@ -35,4 +35,4 @@ validateCost : String -> Translations -> Result String Int validateCost cost translations = cost |> validateNonEmpty (getMessage "CostRequired" translations) - |> flip Result.andThen (validateNumber (getMessage "CostMustBeNumber" translations)) + |> flip Result.andThen (validateNumber (getMessage "CostMustBeNumber" translations) (\number -> number >= 0)) 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 diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs index 7bc821e..62381a7 100644 --- a/src/server/Model/Message/Translations.hs +++ b/src/server/Model/Message/Translations.hs @@ -57,7 +57,7 @@ m l SignInUsed = m l SignInExpired = case l of English -> "The link expired, please sign in again." - French -> "Le lien sur lequel tu as cliqué est expiré, connecte-toi à nouveau." + French -> "Le lien sur lequel tu as cliqué a expiré, connecte-toi à nouveau." m l SignInInvalid = case l of @@ -91,8 +91,8 @@ m l SignInLinkMail = m l SignInEmailSent = case l of - English -> "We sent you an email, please click to the provided link in order to sign in." - French -> "Nous t'avons envoyé un courriel, clique sur le lien dans ce mail pour te connecter." + English -> "We sent you an email with a connexion link." + French -> "Nous t'avons envoyé un courriel avec un lien pour te connecter." -- Date @@ -165,18 +165,18 @@ m l Date = m l CategoryRequired = case l of - English -> "The category is required." - French -> "La catégorie est requise." + English -> "Type a category." + French -> "Entre une catégorie." m l CostRequired = case l of - English -> "The cost is required." - French -> "Le coût est requis." + English -> "Type a cost." + French -> "Entre un coût." m l CostMustBeNumber = case l of - English -> "The cost must be a number." - French -> "Le coût doit être un nombre." + English -> "The cost must be a positive natural number." + French -> "Le coût doit être un entier positif." -- Payments -- cgit v1.2.3