Skip to content
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

Branch input validation #75

Merged

Conversation

chowyiyin
Copy link

Added policy class and new fields to person.
Added addpolicycommand.
UI can now display new person fields.
Tests are incomplete (6 still failing).

Remove policy field when adding new person
Change ListCommand to ListPeopleCommand
Change ListCommand to ListPeopleCommand
…n/main into branch-input-validation

# Conflicts:
#	docs/UserGuide.adoc
#	src/main/java/seedu/address/logic/commands/AddPolicyCommand.java
#	src/main/java/seedu/address/logic/commands/EditCommand.java
#	src/main/java/seedu/address/logic/parser/AddCommandParser.java
#	src/main/java/seedu/address/logic/parser/AddPolicyCommandParser.java
#	src/main/java/seedu/address/logic/parser/AddressBookParser.java
#	src/main/java/seedu/address/logic/parser/ParserUtil.java
#	src/main/java/seedu/address/model/Model.java
#	src/main/java/seedu/address/model/person/DateOfBirth.java
#	src/main/java/seedu/address/model/person/Nric.java
#	src/main/java/seedu/address/model/person/Person.java
#	src/main/java/seedu/address/model/policy/Coverage.java
#	src/main/java/seedu/address/model/policy/EndAge.java
#	src/main/java/seedu/address/model/policy/Policy.java
#	src/main/java/seedu/address/model/policy/Price.java
#	src/main/java/seedu/address/model/policy/StartAge.java
#	src/main/java/seedu/address/model/policy/UniquePolicyList.java
#	src/main/java/seedu/address/model/policy/exceptions/DuplicatePolicyException.java
#	src/main/java/seedu/address/model/util/SampleDataUtil.java
#	src/main/java/seedu/address/storage/JsonAdaptedPerson.java
#	src/main/java/seedu/address/storage/JsonAdaptedPolicy.java
"phone" : "98765432",
"email" : "johnd@example.com",
"address" : "311, Clementi Ave 2, #02-25",
"tagged" : [ "owesMoney", "friends" ]
"date of birth" : "12.12.1922",
"policies" : [ ["SeniorCare", "SeniorCare", "months/12", "$1000" ],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra square bracket

"phone" : "87652533",
"email" : "cornelia@example.com",
"address" : "10th street",
"tagged" : [ "friends" ]
"date of birth" : "14.2.2019",
"policies" : [ ["Infant Insurance", "Infant Insurance", "years/2", "$1500"] ],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this wrapped under an extra set of square brackets?

@chowyiyin
Copy link
Author

chowyiyin commented Oct 6, 2019 via email

public class Nric {

public static final String MESSAGE_CONSTRAINTS =
"This is not a valid Singapore Idenfication number.\n" +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo "Idenfication"

"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 at least 3 digits long.\n";
public static final String VALIDATION_REGEX = "\\d{3,8}";
public final String value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can consider this phone validation regex instead? I think it suits sg context better.

https://www.regextester.com/104145

@larrylawl
Copy link

larrylawl commented Oct 6, 2019

wow this is alot of work! thanks so much yi yin! I didn't have much time to look through the code in detail, but I did smoke tests and they work fine (other than input validation for phone number).

i'd also suggest to add // TODO: ... in places which the team needs to look into further in the future (such as the tests which are failing), so that we don't forget about what exactly needs to be fixed.

@JsonProperty("tagged") List<JsonAdaptedTag> tagged) {
this.name = name;
this.description = description;
this.coverage = coverage;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2019-10-07 at 2 10 00 AM
Yo i'm trying to fix the test cases.

Test case:toModelType_validPersonDetails_returnsPerson
In SampleDataUtil, new Coverage(" days/10 months/11 years/12")
However in the model, coverage takes in the argument 10 days 11 months 12 years, which leads to coverage being null as it is not able to parse the correct format using getCoverageBreakdown.

However, is coverage meant to be doing the parsing? cuz in sample data util, the arguments are the content itself.

Copy link

@ybchen97 ybchen97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sup Yiyin, awesome work here! That's a monster of a pr, thanks for lifting this heavy load. I have left a few comments here and there, the ones with "Note:" are not directed towards you, they just there to note down some potential discrepancies, or raise up certain issues which we could discuss about as a group. Other than that there's one thing I want to mention:

I realised that our addperson command allows the user to add policies and tags when creating a new contact, but editperson does not allow that, which might be a little confusing for both the user and us. I was thinking that since we already have the commands assignpolicy, unassignpolicy, addtag, deletetag why not just separate the adding/editing of policies and tags entirely and leave that responsibility to the various commands mentioned. This means that addperson and editperson only touches the particulars of the contact, while anything else related to policies and tags will have their own helper commands like the ones raised above. This allows us and our users to draw a distinct line between things related to person, tags, and policies, which i think makes the user workflow simpler. The same goes for addpolicy and editpolicy.

I think we should discuss this, let us know what you and oli think during your meeting tonight! Thanks again :D

public static final Prefix PREFIX_PHONE = new Prefix("p/");
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_DATE_OF_BIRTH = new Prefix("dob/");
public static final Prefix PREFIX_POLICY = new Prefix("pol/");
public static final Prefix PREFIX_TAG = new Prefix("t/");

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but might want to add a comment here to denote policy prefixes

Comment on lines 54 to 59
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

model.addPolicy(toAdd);
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • Duplicate policy not yet implemented, also resulting in no CommandException being thrown (referencing to AddCommand.java)

@@ -8,9 +8,9 @@
/**
* Lists all persons in the address book to the user.
*/
public class ListCommand extends Command {
public class ListPeopleCommand extends Command {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • What purpose does this command actually serve to the user, since the main page already lists all the contacts in the addressbook?

@Override
public void addPolicy(Policy policy) {
addressBook.addPolicy(policy);
updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • addPolicy should update policy list instead of person list?

@larrylawl larrylawl merged commit 3088530 into AY1920S1-CS2103-F09-4:master Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants