Skip to content

Commit

Permalink
Fix entering more than 40 chars worth of emails to dice server. (#11805)
Browse files Browse the repository at this point in the history
* Fix entering more than 40 chars worth of emails to dice server.

* Formatting.
  • Loading branch information
asvitkine committed Jul 23, 2023
1 parent 84d2843 commit 17542ce
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.net.URI;
import java.util.Arrays;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -256,9 +257,9 @@ private void checkFieldsAndNotify() {

public boolean areFieldsValid() {
final boolean toValid =
!toAddress.getText().isEmpty() && PlayerEmailValidation.isValid(toAddress.getText());
!toAddress.getText().isEmpty() && validateEmailAddresses(toAddress.getText());
final boolean ccValid =
!ccAddress.getText().isEmpty() && PlayerEmailValidation.isValid(ccAddress.getText());
!ccAddress.getText().isEmpty() && validateEmailAddresses(ccAddress.getText());

final boolean allValid = toValid && ccValid;
testDiceButton.setEnabled(allValid);
Expand All @@ -275,6 +276,10 @@ public boolean areFieldsValid() {
return allValid;
}

private boolean validateEmailAddresses(String addresses) {
return Arrays.stream(addresses.split("\\s+")).allMatch(PlayerEmailValidation::isValid);
}

public void applyToGameProperties(final GameProperties properties) {
properties.set(IRemoteDiceServer.GAME_NAME, gameId.getText());
properties.set(IRemoteDiceServer.EMAIL_1, toAddress.getText());
Expand Down

0 comments on commit 17542ce

Please sign in to comment.