Skip to content
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
6 changes: 5 additions & 1 deletion src/seedu/addressbook/data/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public Email(String email, boolean isPrivate) throws IllegalValueException {
* Returns true if the given string is a valid person email.
*/
public static boolean isValidEmail(String test) {
return test.matches(EMAIL_VALIDATION_REGEX);
Boolean check = true;
if(test.contains("/*") || test.contains(";") || test.contains("'") || test.contains("*/")) {
check = false;
}
return test.matches(EMAIL_VALIDATION_REGEX) && check;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/seedu/addressbook/data/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Phone(String phone, boolean isPrivate) throws IllegalValueException {
* Returns true if the given string is a valid person phone number.
*/
public static boolean isValidPhone(String test) {
return test.matches(PHONE_VALIDATION_REGEX);
return test.matches(PHONE_VALIDATION_REGEX) && test.length() >= 3;
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
|| Enter command: || [Command entered: add Valid Name p/12345 e/valid@e.mail a/valid, address t/invalid_-[.tag]
|| Tags names should be alphanumeric
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/00 e/valid@e.mail]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 e/this;email@contains.semicolon]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you have added multiple test cases!

|| Enter command: || [Command entered: add Adam Brown p/111111 e/adam@gmail.com a/111, alpha street]
|| New person added: Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags:
|| ===================================================
Expand Down
6 changes: 6 additions & 0 deletions test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
add Valid Name p/12345 e/notAnEmail a/valid, address
add Valid Name p/12345 e/valid@e.mail a/valid, address t/invalid_-[.tag

# should catch invalid phone data
add Valid Name p/00 e/valid@e.mail

# should catch invalid email data
add Valid Name p/12345 e/this;email@contains.semicolon

# should add correctly and list non private information
add Adam Brown p/111111 e/adam@gmail.com a/111, alpha street
list
Expand Down