diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 4079629a3d2..c100ea3a9e8 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -8,6 +8,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; +import seedu.address.logic.Messages; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Birthday; @@ -157,6 +158,9 @@ public static Birthday parseDob(String dob) throws ParseException { public static Claim parseClaim(String claimAmount) throws ParseException { requireNonNull(claimAmount); String trimmed = claimAmount.trim(); + if (trimmed.length() > 14) { + throw new ParseException(Messages.TOO_LARGE_A_NUMBER); + } if (!Claim.comtainsSymbol(trimmed)) { throw new ParseException(Claim.NO_SYMBOLS_ERROR); } else if (!Claim.isCorrectAmountType(trimmed)) { diff --git a/src/test/java/seedu/address/logic/parser/ClaimCommandParserTest.java b/src/test/java/seedu/address/logic/parser/ClaimCommandParserTest.java index 4be2552a218..9751326e279 100644 --- a/src/test/java/seedu/address/logic/parser/ClaimCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/ClaimCommandParserTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; +import seedu.address.logic.Messages; import seedu.address.logic.commands.ClaimCommand; public class ClaimCommandParserTest { @@ -35,6 +36,12 @@ public void parse_withEmptyIndex_returnsFailure() { assertParseFailure(parser, userInput, CLAIM_EMPTY_INDEX); } + @Test + public void parse_claimTooLarge_returnsFailure() { + String userInput = "1 $/+100000000000000000000000000000000"; + assertParseFailure(parser, userInput, Messages.TOO_LARGE_A_NUMBER); + } + @Test public void parse_withEmptyAmount_returnsFailure() { String userInput = String.valueOf(INDEX_FIRST_PERSON.getOneBased());