diff --git a/docs/UserGuide.md b/docs/UserGuide.md
index 6500388a253..371fcf16c8a 100644
--- a/docs/UserGuide.md
+++ b/docs/UserGuide.md
@@ -157,7 +157,7 @@ Notes:
* `AREA` can be either 'east', 'southeast', 'south', 'southwest', 'west', 'northwest', 'north', or 'northeast'.
* `DETAILS` is optional and refers to the housekeeping details for CLIENT ONLY. It is not applicable for housekeepers.
The format for `DETAILS` is `d/yyyy-MM-dd NUMBER INTERVAL` where `yyyy-MM-dd` is the date of the last
-housekeeping, `NUMBER` is the quantity of `INTERVAL`(s) which can be ***'days', 'weeks', 'months' or 'years'.***
+housekeeping, `NUMBER` is the (non-negative) quantity of `INTERVAL`(s) which can be ***'days', 'weeks', 'months' or 'years'.***
This `INTERVAL` is the period between housekeeping sessions that the client prefers. It is meant to be an estimate, so
options such as `2 weeks and 3 days` are not supported. If precision is needed, you should convert it to `NUMBER days`.
@@ -289,7 +289,7 @@ General format: `booking TYPE ACTION INDEX [PARAMETERS]`
:bulb: **Tip:**
For the subcommands of booking below, here are some clarifications.
`INDEX` refers to the index of the observed client/housekeeper list.
-`NUMBER` refers to any integer. This could represent the quantity of `INTERVAL`(s).
+`NUMBER` refers to a non-negative integer. This could represent the quantity of `INTERVAL`(s).
`INTERVAL` refers to a period, which can be 'days', 'weeks', 'months' or 'years'.
This `INTERVAL` is the period between housekeeping sessions that the client prefers. It is meant to be an estimate, so
options such as `2 weeks and 3 days` are not supported. If precision is needed, you should convert it to `NUMBER days`.
diff --git a/src/main/java/housekeeping/hub/logic/parser/ParserUtil.java b/src/main/java/housekeeping/hub/logic/parser/ParserUtil.java
index b22ff788ebd..d79c22fd1de 100644
--- a/src/main/java/housekeeping/hub/logic/parser/ParserUtil.java
+++ b/src/main/java/housekeeping/hub/logic/parser/ParserUtil.java
@@ -214,6 +214,9 @@ public static Period parsePreferredInterval(String pI) throws ParseException {
String[] splitPI = trimmedPI.split("\\s+");
Period period;
int quantity = Integer.parseInt(splitPI[0]);
+ if (quantity <= 0) {
+ throw new ParseException(HousekeepingDetails.MESSAGE_CONSTRAINTS);
+ }
switch (splitPI[1]) {
case "days":
period = Period.ofDays(quantity);
@@ -254,6 +257,9 @@ public static HousekeepingDetails parseHousekeepingDetails(Optional deta
s = trimmedDetails.split(" ");
date = LocalDate.parse(s[0]);
quantity = Integer.parseInt(s[1]);
+ if (quantity <= 0) {
+ throw new ParseException(HousekeepingDetails.MESSAGE_CONSTRAINTS);
+ }
} catch (DateTimeParseException e) {
throw new ParseException(e.getMessage());
}