Skip to content

Commit

Permalink
Remove phone and email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jollybomber committed Nov 11, 2024
1 parent 98f7e04 commit fea7dc7
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 59 deletions.
10 changes: 0 additions & 10 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}

if (model.hasDuplicatePhone(editedPerson.getPhone())
&& !personToEdit.getPhone().equals(editedPerson.getPhone())) {
throw new CommandException("This phone number is already in use.");
}

if (model.hasDuplicateEmail(editedPerson.getEmail())
&& !personToEdit.getEmail().equals(editedPerson.getEmail())) {
throw new CommandException("This email address is already in use.");
}

for (Lesson l : model.getAssociatedLessons(personToEdit)) {
model.deleteLesson(l);
if (editedPerson.isTutor()) {
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import javafx.collections.ObservableList;
import seedu.address.commons.core.GuiSettings;
import seedu.address.model.lesson.Lesson;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;

/**
Expand Down Expand Up @@ -123,10 +121,6 @@ public interface Model {
*/
void updateFilteredPersonList(Predicate<Person> predicate);

public boolean hasDuplicatePhone(Phone phone);

public boolean hasDuplicateEmail(Email email);

//@@author estellelim-reused
//Reused from https://github.com/se-edu/addressbook-level4.git
/**
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.lesson.Lesson;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;

/**
Expand Down Expand Up @@ -189,21 +187,6 @@ public void commitAddressBook() {
versionedAddressBook.commit();
}

/**
* Returns true if the model has person with the same phone number as the given phone.
*/
public boolean hasDuplicatePhone(Phone phone) {
return getFilteredPersonList().stream()
.anyMatch(person -> person.getPhone().equals(phone));
}

/**
* Returns true if the model has person with the same email as the given email.
*/
public boolean hasDuplicateEmail(Email email) {
return getFilteredPersonList().stream()
.anyMatch(person -> person.getEmail().equals(email));
}
//@@author

@Override
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ public boolean isSamePerson(Person otherPerson) {
return true;
}

boolean res = otherPerson != null
return otherPerson != null
&& otherPerson.getName().equals(getName()) && otherPerson.getPhone().equals(getPhone());
return res;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.lesson.Lesson;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;
import seedu.address.model.person.Tutee;
import seedu.address.testutil.TuteeBuilder;
Expand Down Expand Up @@ -202,16 +200,6 @@ public void updateFilteredPersonList(Predicate<Person> predicate) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean hasDuplicateEmail(Email email) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean hasDuplicatePhone(Phone phone) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean canUndoAddressBook() {
throw new AssertionError("This method should not be called.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.lesson.Lesson;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;
import seedu.address.model.person.Tutor;
import seedu.address.testutil.TutorBuilder;
Expand Down Expand Up @@ -202,16 +200,6 @@ public void updateFilteredPersonList(Predicate<Person> predicate) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean hasDuplicateEmail(Email email) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean hasDuplicatePhone(Phone phone) {
throw new AssertionError("This method should not be called.");
}

@Override
public boolean canUndoAddressBook() {
throw new AssertionError("This method should not be called.");
Expand Down

0 comments on commit fea7dc7

Please sign in to comment.