Skip to content

Commit

Permalink
Fix phone number constraints.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxunn committed Nov 7, 2023
1 parent d927fa1 commit 777eab8
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 @@ -11,7 +11,8 @@ public class Phone {


public static final String MESSAGE_CONSTRAINTS =
"Phone numbers should only contain numbers, and it should be at least 3 digits long";
"Phone number should only contain numbers. Phone number should be at least 3 digits long "
+ "and should not be longer than 8 digits.";
public static final String VALIDATION_REGEX = "\\d{3,}";
public final String value;

Expand All @@ -30,9 +31,11 @@ public Phone(String phone) {
* Returns true if a given string is a valid phone number.
*/
public static boolean isValidPhone(String test) {
return test.matches(VALIDATION_REGEX);
return test.matches(VALIDATION_REGEX) && (test.length() >= 3 && test.length() <= 8);
}



@Override
public String toString() {
return value;
Expand Down

0 comments on commit 777eab8

Please sign in to comment.