diff --git a/src/main/java/seedu/address/model/patient/Name.java b/src/main/java/seedu/address/model/patient/Name.java index 77b27c4af47..899e17f37b8 100644 --- a/src/main/java/seedu/address/model/patient/Name.java +++ b/src/main/java/seedu/address/model/patient/Name.java @@ -10,13 +10,14 @@ public class Name { public static final String MESSAGE_CONSTRAINTS = - "Names should only contain alphanumeric characters and spaces, and it should not be blank"; + "Names should not be blank, and can only contain letters or a special character (space, " + + "slash \nor dash) surrounded by letters."; /* * The first character of the address must not be a whitespace, * otherwise " " (a blank string) becomes a valid input. */ - public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; + public static final String VALIDATION_REGEX = "[A-Za-z](([ -/\\\\][A-Za-z])|[A-Za-z])*"; public final String fullName; diff --git a/src/test/java/seedu/address/model/patient/NameTest.java b/src/test/java/seedu/address/model/patient/NameTest.java index 9903bc9234e..1e848b17545 100644 --- a/src/test/java/seedu/address/model/patient/NameTest.java +++ b/src/test/java/seedu/address/model/patient/NameTest.java @@ -27,15 +27,14 @@ public void isValidName() { // invalid name assertFalse(Name.isValidName("")); // empty string assertFalse(Name.isValidName(" ")); // spaces only - assertFalse(Name.isValidName("^")); // only non-alphanumeric characters - assertFalse(Name.isValidName("peter*")); // contains non-alphanumeric characters + assertFalse(Name.isValidName("^")); // only non-alphabets + assertFalse(Name.isValidName("peter*")); // contains disallowed character // valid name assertTrue(Name.isValidName("peter jack")); // alphabets only - assertTrue(Name.isValidName("12345")); // numbers only - assertTrue(Name.isValidName("peter the 2nd")); // alphanumeric characters + assertTrue(Name.isValidName("peter-jack")); // - between alphabets assertTrue(Name.isValidName("Capital Tan")); // with capital letters - assertTrue(Name.isValidName("David Roger Jackson Ray Jr 2nd")); // long names + assertTrue(Name.isValidName("David Roger Jackson Ray Jr The Almighty")); // long names } @Test diff --git a/src/test/java/seedu/address/model/patient/PatientTest.java b/src/test/java/seedu/address/model/patient/PatientTest.java index 2f63330a461..67bc971e12e 100644 --- a/src/test/java/seedu/address/model/patient/PatientTest.java +++ b/src/test/java/seedu/address/model/patient/PatientTest.java @@ -42,10 +42,6 @@ public void isSamePatient() { Patient editedBob = new PatientBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); assertFalse(BOB.isSamePatient(editedBob)); - // different phone number, all other attributes same -> returns false - editedBob = new PatientBuilder(BOB).withPhone(VALID_PHONE_AMY).build(); - assertFalse(BOB.isSamePatient(editedBob)); - // different phone number and different name, all other attributes same -> returns false editedBob = new PatientBuilder(BOB).withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).build(); assertFalse(BOB.isSamePatient(editedBob));