diff --git a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java index a949e8c56aa..1a0bc803e76 100644 --- a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java +++ b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java @@ -30,9 +30,10 @@ static Void validateNumericString(String numericString, int maxDecimalPlace, int String messageNotANumber, String messageTooPrecise, String messageTooLarge, String messageIsNegative) { boolean isParsable = ValidationUtil.isParsableDouble(numericString); + boolean hasNoSpecialChars = numericString.matches("[0-9.-]*"); boolean isTooPrecise = ValidationUtil.isDoubleTooPrecise(numericString, maxDecimalPlace); - checkArgument(isParsable, messageNotANumber); + checkArgument(isParsable && hasNoSpecialChars, messageNotANumber); checkArgument(!isTooPrecise, messageTooPrecise); double number = Double.parseDouble(numericString);