Skip to content

Commit

Permalink
Merge pull request #358 from yixiann/modify-price-validator
Browse files Browse the repository at this point in the history
Modify price validator to not accept 3.e1
  • Loading branch information
RichDom2185 authored Oct 27, 2022
2 parents a07bb5b + ea0487d commit 3b6aafb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3b6aafb

Please sign in to comment.