Skip to content

Commit

Permalink
Merge pull request #357 from coraleaf0602/Format-Phone-Number
Browse files Browse the repository at this point in the history
Add formatting for phone number
  • Loading branch information
kaboomzxc authored Nov 10, 2024
2 parents ef62847 + c906e9f commit e67250f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/main/java/bookbob/functions/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,10 @@ 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");
// Check if the phone number is exactly 8 digits long, starts with 8 or 9, and contains only digits
if (!phoneNumber.matches("[89]\\d{7}")) {
System.out.println("Please provide a valid local phone number " +
"(must start with 8 or 9 and be 8 digits long)");
return "";
}
}
Expand Down

0 comments on commit e67250f

Please sign in to comment.