Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate guestbook email field #11022

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading