Skip to content

Commit

Permalink
Merge pull request #11022 from IQSS/10661-guestbook-email-field-not-v…
Browse files Browse the repository at this point in the history
…alidated

validate guestbook email field
  • Loading branch information
ofahimIQSS authored Nov 19, 2024
2 parents b812173 + a6d835c commit c0c6b08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/release-notes/10661-guestbook-email-bug-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

### Guestbook Email Validation Bug fix

Guestbook UI Form: Email address is now checked for valid email format
7 changes: 5 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/GuestbookResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import edu.harvard.iq.dataverse.validation.ValidateEmail;
import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import java.util.Collections;
Expand Down Expand Up @@ -80,8 +82,8 @@ public class GuestbookResponse implements Serializable {
@Size(max = 255, message = "{guestbook.response.nameLength}")
private String name;

// TODO: Consider using EMailValidator as well.
@Size(max = 255, message = "{guestbook.response.nameLength}")
@ValidateEmail(message = "{user.invalidEmail}")
private String email;

@Size(max = 255, message = "{guestbook.response.nameLength}")
Expand Down Expand Up @@ -198,7 +200,8 @@ public String getEmail() {
}

public void setEmail(String email) {
this.email = email;
// ValidateEmail requires NULL or valid email. Empty String will fail validation
this.email = (email == null || email.trim().isEmpty()) ? null : email;
}

public Guestbook getGuestbook() {
Expand Down

0 comments on commit c0c6b08

Please sign in to comment.