Skip to content

Commit

Permalink
Edit according to the feedback given by my teammates
Browse files Browse the repository at this point in the history
  • Loading branch information
alphajae11 committed Apr 14, 2024
1 parent cbbbc8a commit b5dfc54
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public class Phone {

public static final String MESSAGE_CONSTRAINTS =
"Phone numbers should only contain numbers, and it should be 8 digits long "
+ "according to Singapore mobile number format";
public static final String VALIDATION_REGEX = "\\d{8}";
+ "according to Singapore mobile number format which starts with"
+ "8 or 9.";
public static final String VALIDATION_REGEX = "^[89]\\d{7}";
public final String value;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class CommandTestUtil {

public static final String VALID_NAME_AMY = "Amy Bee";
public static final String VALID_NAME_BOB = "Bob Choo";
public static final String VALID_PHONE_AMY = "11111111";
public static final String VALID_PHONE_BOB = "22222222";
public static final String VALID_PHONE_AMY = "88888888";
public static final String VALID_PHONE_BOB = "99999999";
public static final String VALID_EMAIL_AMY = "[email protected]";
public static final String VALID_EMAIL_BOB = "[email protected]";
public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ParserUtilTest {
private static final String INVALID_ROLE = "#friend";

private static final String VALID_NAME = "Rachel Walker";
private static final String VALID_PHONE = "12345678";
private static final String VALID_PHONE = "87654321";
private static final String VALID_ADDRESS = "123 Main Street #0505";
private static final String VALID_EMAIL = "[email protected]";
private static final String VALID_ROLE_1 = "friend";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void test_nameDoesNotContainKeywords_returnsFalse() {
assertFalse(predicate.test(new PersonBuilder().withName("Alice Bob").build()));

// Keywords match phone, email and address, but does not match name
predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345678", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345678")
predicate = new NameContainsKeywordsPredicate(Arrays.asList("87654321", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("87654321")
.withEmail("[email protected]").withAddress("Main Street").build()));
}

Expand Down
6 changes: 4 additions & 2 deletions src/test/java/seedu/address/model/person/PhoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public void isValidPhone() {
// invalid phone numbers
assertFalse(Phone.isValidPhone("")); // empty string
assertFalse(Phone.isValidPhone(" ")); // spaces only
assertFalse(Phone.isValidPhone("9190137")); // less than 38 numbers
assertFalse(Phone.isValidPhone("9190137")); // less than 8 numbers
assertFalse(Phone.isValidPhone("12345678")); // Does not start with 8 or 9
assertFalse(Phone.isValidPhone("phone")); // non-numeric
assertFalse(Phone.isValidPhone("9011p041")); // alphabets within digits
assertFalse(Phone.isValidPhone("9312 1534")); // spaces within digits
assertFalse(Phone.isValidPhone("17803682394326478")); // More than 8 number

// valid phone numbers
assertTrue(Phone.isValidPhone("93121534")); // exactly 8 numbers
assertTrue(Phone.isValidPhone("87779381")); // exactly 8 numbers starting with 8 or 9
assertTrue(Phone.isValidPhone("93121534")); // exactly 8 numbers starting with 8 or 9
}

@Test
Expand Down

0 comments on commit b5dfc54

Please sign in to comment.