Skip to content

Commit

Permalink
Update CommandHandler.java
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceCatt authored Nov 9, 2024
1 parent 903c37c commit e7124bc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/bookbob/functions/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,15 @@ private String extractPhoneNumber(String input) {
int phoneEnd = findNextFieldStart(input, phoneStart + lengthOfPhoneNumberIndicator);
phoneNumber = input.substring(phoneStart + lengthOfPhoneNumberIndicator, phoneEnd).trim();
}
if (!phoneNumber.matches("[0-9]+")) {
System.out.println("Please provide a valid local phone number");
return "";
}
int number = Integer.parseInt(phoneNumber);
if (number < 80000000 && number > 99999999) {
System.out.println("Please provide a valid local phone number");
return "";
}
return phoneNumber;
}

Expand Down

0 comments on commit e7124bc

Please sign in to comment.