Skip to content

Commit

Permalink
Merge pull request #246 from yuehernkang/fix-type-filter-accept-only-…
Browse files Browse the repository at this point in the history
…property-type

PropertyType and PropertyStatus to reject invalid input
  • Loading branch information
yuehernkang authored Nov 7, 2022
2 parents a3e9a3f + 8a55769 commit be25591
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import seedu.condonery.logic.commands.property.StatusPropertyCommand;
import seedu.condonery.logic.parser.Parser;
import seedu.condonery.logic.parser.ParserUtil;
import seedu.condonery.logic.parser.exceptions.ParseException;
import seedu.condonery.model.property.PropertyStatusContainsKeywordsPredicate;

Expand All @@ -28,6 +29,11 @@ public StatusPropertyCommand parse(String args) throws ParseException {

String[] nameKeywords = trimmedArgs.split("\\s+");

for (int i = 0; i < nameKeywords.length; i++) {
ParserUtil.parsePropertyStatus(
nameKeywords[i]);
}

return new StatusPropertyCommand(new PropertyStatusContainsKeywordsPredicate(Arrays.asList(nameKeywords)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import seedu.condonery.logic.commands.property.TypePropertyCommand;
import seedu.condonery.logic.parser.Parser;
import seedu.condonery.logic.parser.ParserUtil;
import seedu.condonery.logic.parser.exceptions.ParseException;
import seedu.condonery.model.property.PropertyTypeContainsKeywordsPredicate;

Expand All @@ -25,9 +26,13 @@ public TypePropertyCommand parse(String args) throws ParseException {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, TypePropertyCommand.MESSAGE_USAGE));
}

String[] nameKeywords = trimmedArgs.split("\\s+");

for (int i = 0; i < nameKeywords.length; i++) {
ParserUtil.parsePropertyType(
nameKeywords[i]);
}

return new TypePropertyCommand(new PropertyTypeContainsKeywordsPredicate(Arrays.asList(nameKeywords)));
}

Expand Down

0 comments on commit be25591

Please sign in to comment.