Skip to content

Commit

Permalink
feat[DonationController]: prevent donations that are too large or wit…
Browse files Browse the repository at this point in the history
…h too many decimals

Add error message when trying to donate an amount of money that has too many digits or decimals.
  • Loading branch information
Lucy Ciara Herud-Thomassen authored and Lucy Ciara Herud-Thomassen committed Apr 21, 2026
1 parent 58d80d9 commit f22ad07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/edu/group5/app/control/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/edu/group5/app/control/DonationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f22ad07

Please sign in to comment.