diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/person/Phone.java index d733f63d739..49f0cba3071 100644 --- a/src/main/java/seedu/address/model/person/Phone.java +++ b/src/main/java/seedu/address/model/person/Phone.java @@ -11,8 +11,10 @@ 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 8 digits long " + + "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; /** diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index 4270ea1e67f..d6165ae19da 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -55,7 +55,7 @@ "metadata": "I like to play basketball." }, { "name" : "Elle Meyer", - "phone" : "9482224", + "phone" : "94822242", "email" : "werner@example.com", "address" : "michegan ave", "roles" : [ ], @@ -68,7 +68,7 @@ "metadata": "I support Manchester United." }, { "name" : "Fiona Kunz", - "phone" : "9482427", + "phone" : "94824272", "email" : "lydia@example.com", "address" : "little tokyo", "roles" : [ ], @@ -81,7 +81,7 @@ "metadata": "I support Manchester United." }, { "name" : "George Best", - "phone" : "9482442", + "phone" : "94824422", "email" : "anna@example.com", "address" : "4th street", "roles" : [ ], diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 04fc6996e6d..2d6fd0b5fd8 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -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 = "amy@example.com"; public static final String VALID_EMAIL_BOB = "bob@example.com"; public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index f128c4ba53d..a1512f55cda 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -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 = "123456"; + private static final String VALID_PHONE = "87654321"; private static final String VALID_ADDRESS = "123 Main Street #0505"; private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_ROLE_1 = "friend"; diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java index 6b3fd90ade7..b5287e4b8dc 100644 --- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java @@ -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("12345", "alice@email.com", "Main", "Street")); - assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345") + predicate = new NameContainsKeywordsPredicate(Arrays.asList("87654321", "alice@email.com", "Main", "Street")); + assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("87654321") .withEmail("alice@email.com").withAddress("Main Street").build())); } diff --git a/src/test/java/seedu/address/model/person/PhoneTest.java b/src/test/java/seedu/address/model/person/PhoneTest.java index deaaa5ba190..44a07281202 100644 --- a/src/test/java/seedu/address/model/person/PhoneTest.java +++ b/src/test/java/seedu/address/model/person/PhoneTest.java @@ -27,23 +27,24 @@ 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("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("911")); // exactly 3 numbers - assertTrue(Phone.isValidPhone("93121534")); - assertTrue(Phone.isValidPhone("124293842033123")); // long phone 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 public void equals() { - Phone phone = new Phone("999"); + Phone phone = new Phone("99171577"); // same values -> returns true - assertTrue(phone.equals(new Phone("999"))); + assertTrue(phone.equals(new Phone("99171577"))); // same object -> returns true assertTrue(phone.equals(phone)); @@ -55,6 +56,6 @@ public void equals() { assertFalse(phone.equals(5.0f)); // different values -> returns false - assertFalse(phone.equals(new Phone("995"))); + assertFalse(phone.equals(new Phone("99580770"))); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 33cd2968c0a..dc037f005ed 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -56,23 +56,23 @@ public class TypicalPersons { .withAtt("0") .withSess("1") .withMetadata("I like to play basketball.").build(); - public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("94822242") .withEmail("werner@example.com").withAddress("michegan ave").withMetadata("I support Manchester United.") .build(); - public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("94824272") .withEmail("lydia@example.com").withAddress("little tokyo") .withAmount("50.00") .withAtt("0") .withSess("1") .withMetadata("I support Manchester United.").build(); - public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("94824422") .withEmail("anna@example.com").withAddress("4th street").withMetadata("I support Manchester United.") .build(); // Manually added - public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("84824242") .withEmail("stefan@example.com").withAddress("little india").build(); - public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("84821312") .withEmail("hans@example.com").withAddress("chicago ave").build(); // Manually added - Person's details found in {@code CommandTestUtil}