Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103-F13-2#205 from nixonwidjaja/master
Browse files Browse the repository at this point in the history
Fix phone bug
  • Loading branch information
nixonwidjaja authored Nov 13, 2023
2 parents 9dd49ac + ac83f53 commit 913403c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/seedu/address/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ public Phone(String phone) {
* Returns true if a given string is a valid phone number.
*/
public static boolean isValidPhone(String test) {
if (test.length() < 3 || test.length() > 20) {
if (test.length() < 3) {
return false;
}
if (test.charAt(0) == '+') {
return test.substring(1).matches(VALIDATION_REGEX);
test = test.substring(1);
}
if (test.length() < 3 || test.length() > 20) {
return false;
}
return test.matches(VALIDATION_REGEX);
}
Expand Down

0 comments on commit 913403c

Please sign in to comment.