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

More permissive e-mail validation #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/seedu/addressbook/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,7 @@ private static boolean isPersonPhoneValid(String phone) {
* @return whether arg is a valid person email
*/
private static boolean isPersonEmailValid(String email) {
return email.matches("\\S+@\\S+\\.\\S+"); // email is [non-whitespace]@[non-whitespace].[non-whitespace]
//TODO: implement a more permissive validation
return email.matches("^.+@.+(\\.[^\\.]+)+$"); // email is [any]@[any, not ending in dot]
}


Expand Down
27 changes: 17 additions & 10 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,26 @@
|| Example: add John Doe p/98765432 e/[email protected]
||
|| ===================================================
|| Enter command: || [Command entered: add Adam Brown p/111111 e/[email protected]]
|| New person added: Adam Brown, Phone: 111111, Email: [email protected]
|| Enter command: || [Command entered: add Valid Name p/12345 e/thisEndsInADot.]
|| Invalid command format: add
|| add: Adds a person to the address book.
|| Parameters: NAME p/PHONE_NUMBER e/EMAIL
|| Example: add John Doe p/98765432 e/[email protected]
||
|| ===================================================
|| Enter command: || [Command entered: add Azusagawa Kaede p/111111 e/"Azusagawa Kaede"@[192.168.2.1]]
|| New person added: Azusagawa Kaede, Phone: 111111, Email: "Azusagawa Kaede"@[192.168.2.1]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
||
|| 1 persons found!
|| ===================================================
|| Enter command: || [Command entered: add Betsy Choo p/222222 e/[email protected]]
|| New person added: Betsy Choo, Phone: 222222, Email: [email protected]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
||
|| 2 persons found!
Expand All @@ -142,7 +149,7 @@
|| New person added: Charlie Dickson, Phone: 333333, Email: [email protected]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
|| 3. Charlie Dickson Phone Number: 333333 Email: [email protected]
||
Expand All @@ -152,7 +159,7 @@
|| New person added: Dickson Ee, Phone: 444444, Email: [email protected]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
|| 3. Charlie Dickson Phone Number: 333333 Email: [email protected]
|| 4. Dickson Ee Phone Number: 444444 Email: [email protected]
Expand All @@ -163,7 +170,7 @@
|| New person added: Esther Potato, Phone: 555555, Email: [email protected]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
|| 3. Charlie Dickson Phone Number: 333333 Email: [email protected]
|| 4. Dickson Ee Phone Number: 444444 Email: [email protected]
Expand Down Expand Up @@ -242,7 +249,7 @@
|| Person could not be found in address book
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
|| 3. Dickson Ee Phone Number: 444444 Email: [email protected]
|| 4. Esther Potato Phone Number: 555555 Email: [email protected]
Expand All @@ -253,14 +260,14 @@
|| Deleted Person: Esther Potato Phone Number: 555555 Email: [email protected]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Adam Brown Phone Number: 111111 Email: [email protected]
|| 1. Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| 2. Betsy Choo Phone Number: 222222 Email: [email protected]
|| 3. Dickson Ee Phone Number: 444444 Email: [email protected]
||
|| 3 persons found!
|| ===================================================
|| Enter command: || [Command entered: delete 1]
|| Deleted Person: Adam Brown Phone Number: 111111 Email: [email protected]
|| Deleted Person: Azusagawa Kaede Phone Number: 111111 Email: "Azusagawa Kaede"@[192.168.2.1]
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Betsy Choo Phone Number: 222222 Email: [email protected]
Expand Down
3 changes: 2 additions & 1 deletion test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
add []\[;] p/12345 e/[email protected]
add Valid Name p/not_numbers e/[email protected]
add Valid Name p/12345 e/notAnEmail
add Valid Name p/12345 e/thisEndsInADot.

# should add correctly
add Adam Brown p/111111 e/[email protected]
add Azusagawa Kaede p/111111 e/"Azusagawa Kaede"@[192.168.2.1]
list
add Betsy Choo p/222222 e/[email protected]
list
Expand Down