AfricasTalkingLtd/africastalking.Net

More robust phone number validation

JobGetabu opened this issue · 3 comments

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

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

okay

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