-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Address optional #74
Make Address optional #74
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, I like how you created data for a new person with only a missing address field for the address for testing!
|
||
// no address | ||
Person expectedPersonNoAddress = new PersonBuilder(CLIVE).build(); | ||
// address tag with blank address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to email and phone PRs, could leave a line break for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- have a few things to clarify though
@@ -12,10 +12,10 @@ public class Address { | |||
public static final String MESSAGE_CONSTRAINTS = "Addresses can take any values, and it should not be blank"; | |||
|
|||
/* | |||
* The first character of the address must not be a whitespace, | |||
* otherwise " " (a blank string) becomes a valid input. | |||
* As the address is now optional, the validation regex accepts a blank address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the comment shouldn't include "now"?
Maybe "Validation regex accepts blank address string because address is optional" would be easier to understand for future devs who have no background knowledge that this was from AB3?
@@ -56,7 +56,7 @@ public EditCommand parse(String args) throws ParseException { | |||
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); | |||
} | |||
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { | |||
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get())); | |||
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).orElse(""))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be misunderstanding this but if argMultimap.getValue(PREFIX_ADDRESS).isPresent()
is true
, then editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).orElse("")))
will always return the argMultimap.getValue(PREFIX_ADDRESS)
value, even if it is a blank string (ie: redundency...?).
Please correct me if I am wrong
@@ -84,11 +91,10 @@ public void toModelType_nullEmail_throwsIllegalValueException() { | |||
} | |||
|
|||
@Test | |||
public void toModelType_invalidAddress_throwsIllegalValueException() { | |||
public void toModelType_blankAddress_returnsPerson() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it better to declare that this function throws IllegalValueException
(from person.toModelType()
)? I see that there is a testcase above that just throws Exception
but maybe IllegalValueException
would be better?
Fixes #55