Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2425S1#146 from JYL27/branch-PhoneNum…
Browse files Browse the repository at this point in the history
…berBug

Fix bug where phone number doesn't adhere to agreed-upon format
  • Loading branch information
btbrandon authored Nov 7, 2024
2 parents 6dd1783 + d7fb986 commit a6c8d1b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class Phone {


public static final String MESSAGE_CONSTRAINTS =
"Phone numbers should only contain numbers, and it should be at least 3 digits long";
public static final String VALIDATION_REGEX = "\\d{3,}";
"Phone numbers should only contain numbers, and it should be at least 8 digits long";
public static final String VALIDATION_REGEX = "\\d{8,}";
public final String value;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}, {
"studentId": "25252525",
"name" : "Elle Meyer",
"phone" : "9482224",
"phone" : "94822244",
"email" : "[email protected]",
"address" : "michegan ave",
"course": "biomedical engineering",
Expand All @@ -68,15 +68,15 @@
}, {
"studentId": "98989898",
"name" : "Fiona Kunz",
"phone" : "9482427",
"phone" : "94824272",
"email" : "[email protected]",
"address" : "little tokyo",
"course": "Data Science",
"tag" : "Tutor"
}, {
"studentId": "28184003",
"name" : "George Best",
"phone" : "9482442",
"phone" : "94824422",
"email" : "[email protected]",
"address" : "4th street",
"course": "Dentistry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ParserUtilTest {
private static final String INVALID_TAG = "#friend";

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

predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345")
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345678")
.withEmail("[email protected]").withAddress("Main Street").build()));
}

Expand Down
11 changes: 5 additions & 6 deletions src/test/java/seedu/address/model/person/PhoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,22 @@ public void isValidPhone() {
// invalid phone numbers
assertFalse(Phone.isValidPhone("")); // empty string
assertFalse(Phone.isValidPhone(" ")); // spaces only
assertFalse(Phone.isValidPhone("91")); // less than 3 numbers
assertFalse(Phone.isValidPhone("911")); // less than 8 numbers
assertFalse(Phone.isValidPhone("phone")); // non-numeric
assertFalse(Phone.isValidPhone("9011p041")); // alphabets within digits
assertFalse(Phone.isValidPhone("9312 1534")); // spaces within digits

// valid phone numbers
assertTrue(Phone.isValidPhone("911")); // exactly 3 numbers
assertTrue(Phone.isValidPhone("93121534"));
assertTrue(Phone.isValidPhone("93121534")); // exactly 8 numbers
assertTrue(Phone.isValidPhone("124293842033123")); // long phone numbers
}

@Test
public void equals() {
Phone phone = new Phone("999");
Phone phone = new Phone("99999999");

// same values -> returns true
assertTrue(phone.equals(new Phone("999")));
assertTrue(phone.equals(new Phone("99999999")));

// same object -> returns true
assertTrue(phone.equals(phone));
Expand All @@ -55,6 +54,6 @@ public void equals() {
assertFalse(phone.equals(5.0f));

// different values -> returns false
assertFalse(phone.equals(new Phone("995")));
assertFalse(phone.equals(new Phone("99599959")));
}
}
10 changes: 5 additions & 5 deletions src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class TypicalPersons {
public static final Person ELLE = new PersonBuilder()
.withStudentId("25252525")
.withName("Elle Meyer")
.withPhone("9482224")
.withPhone("94822244")
.withEmail("[email protected]")
.withAddress("michegan ave")
.withCourse("biomedical engineering")
Expand All @@ -86,7 +86,7 @@ public class TypicalPersons {
public static final Person FIONA = new PersonBuilder()
.withStudentId("98989898")
.withName("Fiona Kunz")
.withPhone("9482427")
.withPhone("94824272")
.withEmail("[email protected]")
.withAddress("little tokyo")
.withCourse("Data Science")
Expand All @@ -95,7 +95,7 @@ public class TypicalPersons {
public static final Person GEORGE = new PersonBuilder()
.withStudentId("28184003")
.withName("George Best")
.withPhone("9482442")
.withPhone("94824422")
.withEmail("[email protected]")
.withAddress("4th street")
.withCourse("Dentistry")
Expand All @@ -108,7 +108,7 @@ public class TypicalPersons {
public static final Person HOON = new PersonBuilder()
.withStudentId("15159888")
.withName("Hoon Meier")
.withPhone("8482424")
.withPhone("84842424")
.withEmail("[email protected]")
.withAddress("little india")
.withCourse("Mechanical engineering")
Expand All @@ -117,7 +117,7 @@ public class TypicalPersons {
public static final Person IDA = new PersonBuilder()
.withStudentId("48883999")
.withName("Ida Mueller")
.withPhone("8482131")
.withPhone("84842131")
.withEmail("[email protected]")
.withAddress("chicago ave")
.withCourse("Architecture")
Expand Down

0 comments on commit a6c8d1b

Please sign in to comment.