Skip to content

Commit

Permalink
Add parseContactId method
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ-Lee01 committed Oct 17, 2023
1 parent 59cc772 commit 70d7ca0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.ContactId;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
Expand Down Expand Up @@ -95,6 +96,21 @@ public static Email parseEmail(String email) throws ParseException {
return new Email(trimmedEmail);
}

/**
* Parses a {@code String contactId} into an {@code ContactId}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code contactId} is invalid.
*/
public static ContactId parseContactId(String contactId) throws ParseException {
requireNonNull(contactId);
String trimmedId = contactId.trim();
if (ContactId.isValidId(trimmedId)) {
throw new ParseException(ContactId.MESSAGE_CONSTRAINTS);
}
return new ContactId(trimmedId);
}

/**
* Parses a {@code String tag} into a {@code Tag}.
* Leading and trailing whitespaces will be trimmed.
Expand Down

0 comments on commit 70d7ca0

Please sign in to comment.