Skip to content

Commit 54a8b69

Browse files
Added Philippine mobile number validation
1 parent 2a2100e commit 54a8b69

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Check.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Text.RegularExpressions;
23

34
namespace CSSimpleFunctions
45
{
@@ -66,6 +67,12 @@ public static bool IsValid(string str)
6667
}
6768
}
6869

70+
public static bool IsAValidPhilippineMobileNumber(string str)
71+
{
72+
string pattern = @"^(?:09|\+639|639)\d{9}$";
73+
return Regex.IsMatch(Regex.Replace(str, @"[\s\-\(\)]", ""), pattern);
74+
}
75+
6976
public static bool HasNumbers(string str)
7077
{
7178
string numbers = "0123456789";

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ Check.HasSymbols("Sample text!"); // returns true
3838
Check.HasSpaces("Sample_text"); // returns false
3939
Check.HasSpaces("Sample text"); // returns true
4040
```
41+
### IsAValidPhilippineMobileNumber
42+
- will check a String if it is a valid Philippine mobile number
43+
- returns a boolean value
44+
```csharp
45+
Check.IsAValidPhilippineMobileNumber("+15551234567"); // returns false
46+
Check.IsAValidPhilippineMobileNumber("09171234567"); // returns true
47+
```
4148
### Email.AddValidDomainName
4249
- adds a valid domain name to the list of valid domain names
4350
```csharp

0 commit comments

Comments
 (0)