aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2015-10-04 21:15:15 +0200
committerJoris2015-10-04 21:15:15 +0200
commitee3027b53aad38178f4945c459a94489f4997507 (patch)
tree0bd93793ac2ea22bdfbe9398a08685246391cce9
parentd920dd95be096dcaa2fa2314d729fdff52631fd6 (diff)
Do not authorize negative incomes
-rw-r--r--src/client/Model/View/LoggedIn/Account.elm2
-rw-r--r--src/server/Model/Message/Key.hs1
-rw-r--r--src/server/Model/Message/Translations.hs5
3 files changed, 7 insertions, 1 deletions
diff --git a/src/client/Model/View/LoggedIn/Account.elm b/src/client/Model/View/LoggedIn/Account.elm
index ab37b81..2bb3ae7 100644
--- a/src/client/Model/View/LoggedIn/Account.elm
+++ b/src/client/Model/View/LoggedIn/Account.elm
@@ -64,4 +64,4 @@ validateIncome : String -> Translations -> Result String Int
validateIncome amount translations =
amount
|> validateNonEmpty (getMessage "IncomeRequired" translations)
- |> flip Result.andThen (validateNumber (getMessage "IncomeMustBeNonNullNumber" translations) ((/=) 0))
+ |> flip Result.andThen (validateNumber (getMessage "IncomeMustBePositiveNumber" translations) (\number -> number > 0))
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index bd2b567..c4ff738 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -47,6 +47,7 @@ data Key =
| CostMustBeNonNullNumber
| IncomeRequired
| IncomeMustBeNonNullNumber
+ | IncomeMustBePositiveNumber
-- Payments
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index f594833..f34cbd2 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -203,6 +203,11 @@ m l IncomeMustBeNonNullNumber =
English -> "The income must be a non-null integer."
French -> "Le revenu doit ĂȘtre un entier non nul."
+m l IncomeMustBePositiveNumber =
+ case l of
+ English -> "The income must be a positive integer."
+ French -> "Le revenu doit ĂȘtre un entier positif."
+
-- Payments
m l Add =