From f22ad07c693b102e8d54bceb7251c2c94d098074 Mon Sep 17 00:00:00 2001 From: Lucy Ciara Herud-Thomassen <86323303+LucyCiara@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:46:16 +0200 Subject: [PATCH] feat[DonationController]: prevent donations that are too large or with too many decimals Add error message when trying to donate an amount of money that has too many digits or decimals. --- src/main/java/edu/group5/app/control/AuthController.java | 2 ++ .../java/edu/group5/app/control/DonationController.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/edu/group5/app/control/AuthController.java b/src/main/java/edu/group5/app/control/AuthController.java index 347a52e..d3d4ebe 100644 --- a/src/main/java/edu/group5/app/control/AuthController.java +++ b/src/main/java/edu/group5/app/control/AuthController.java @@ -86,6 +86,7 @@ public void handleSignUp(SignUpPageView view, String firstName, String lastName, return; } + // Checks if any input is too long. if (firstName.length() > 32 || lastName.length() > 32 || email.length() > 32 || passwordChars.length > 72) { @@ -148,6 +149,7 @@ public void handleSignUp(SignUpPageView view, String firstName, String lastName, return; } + // Privacy policy pop-up. Alert privacyPolicy = new Alert(Alert.AlertType.CONFIRMATION); privacyPolicy.setTitle("Accept Privacy Policy"); privacyPolicy.setHeaderText("Accept Privacy Policy"); diff --git a/src/main/java/edu/group5/app/control/DonationController.java b/src/main/java/edu/group5/app/control/DonationController.java index 07af6fd..3ca392d 100644 --- a/src/main/java/edu/group5/app/control/DonationController.java +++ b/src/main/java/edu/group5/app/control/DonationController.java @@ -178,6 +178,12 @@ private void handleDonate() { return; } + // Prevents donations that are too complex from being made + if (amount.stripTrailingZeros().precision() > 32 || amount.stripTrailingZeros().scale() > 16) { + this.showError("The number is too complex, please donate a smaller or less precise number"); + return; + } + // Create donation via service boolean success = service.donate( customer,