Skip to content

Commit bf13a65

Browse files
committed
Improve PhoneNumber validation
1 parent 5442dc1 commit bf13a65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/KSFramework/Utilities/ValidationExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static bool IsValidEmail(this string email)
1010
return false;
1111
try
1212
{
13-
MailAddress m = new MailAddress(email);
13+
_ = new MailAddress(email);
1414

1515
return true;
1616
}
@@ -22,7 +22,7 @@ public static bool IsValidEmail(this string email)
2222

2323
public static bool IsValidMobile(this string phone)
2424
{
25-
return Regex.Match(phone, @"(\+98|0)?9\d{9}").Success;
25+
return Regex.IsMatch(phone, @"((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}");
2626
}
2727

2828
}

0 commit comments

Comments
 (0)