AfricasTalkingLtd / africastalking.Net

Africa's Talking API Wrapper for C#
https://developers.africastalking.com
MIT License
18 stars 38 forks source link

More robust phone number validation #26

Closed JobGetabu closed 5 years ago

JobGetabu commented 6 years ago
private static bool IsPhoneNumber(string[] number)
        {
            bool valid = true;
            foreach (string num in number)
            {
               var status = Regex.Match(num, @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d{5,}$").Success;
                valid = valid & status;
            }
            return valid;
        }

Have looked at this method of validating numbers. I would suggest use libphonenumber-csharp to enable Parsing/formatting/validating phone numbers for all countries. It has nice goodies backed right in. Test it here

TheBeachMaster commented 6 years ago

Looking at it... Will test on the develop branch.

JobGetabu commented 6 years ago

okay

TheBeachMaster commented 5 years ago

@JobGetabu I'm currently testing with Google Phone number library.Might be coming to master