locked
validate just mobile numbers Google's libphonenumber library RRS feed

  • Question

  • I'm using Google's libphonenumber library in order to mobile number validation. but i want to just accept the mobile numbers and refuse phone numbers in validation process. is this possible?

    here is my phone number validation code:

            Result PhoneContentValidator(string phoneNumber, string region)
        {
            Result result;
            PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
            PhoneNumber phone = phoneUtil.Parse(phoneNumber, region.ToUpper());
    
            try
            {
                if (phoneUtil.IsValidNumber(phone) != true) return result = new Result { resultIsValid = true, resultText = "Not Valid Mobile Number", result = false };
                else return result = new Result { resultIsValid = true, resultText = Main_Log.ApplicationSuccessMessage, result = true };
            }
            catch (Exception ex)
            {
                Main_Log.GetLogger().Error(Main_Log.MessageForLogFile("phone content validation failed due to the exception in application. ", ex.Message, ex.HResult));
                return result = new Result { resultIsValid = false, resultText = ex.Message };
            }
        }

    this method validate both phone and mobile numbers. i want to reject the phone numbers and accept mobile numbers.

    Tuesday, July 7, 2015 5:18 AM

Answers

  • Hi Bouki,

    In MSDN forums, we are talking about Microsoft product and technologies, and this forum is discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Since you mentioned you are developing about Google's libphonenumber library, I am afraid this is out of our support scope. Please redirect this issue is Google's official website for better response. Thanks for your understanding and cooperation.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Bouki Tuesday, August 4, 2015 6:04 PM
    Wednesday, July 8, 2015 2:34 AM

All replies

  • Hi Bouki,

    In MSDN forums, we are talking about Microsoft product and technologies, and this forum is discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Since you mentioned you are developing about Google's libphonenumber library, I am afraid this is out of our support scope. Please redirect this issue is Google's official website for better response. Thanks for your understanding and cooperation.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Bouki Tuesday, August 4, 2015 6:04 PM
    Wednesday, July 8, 2015 2:34 AM
  • Hi Bouki,

    In MSDN forums, we are talking about Microsoft product and technologies, and this forum is discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Since you mentioned you are developing about Google's libphonenumber library, I am afraid this is out of our support scope. Please redirect this issue is Google's official website for better response. Thanks for your understanding and cooperation.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    thank you so much dear Kristin.

    but  i forgot mentioned i added Google's libphonenumber library into my c# project. i think its relevant. i also searched for any tutorial about this library but unfortunately i couldn't find anything.

    however thank you and please accept my apology.

    thank you.

    Wednesday, July 8, 2015 5:05 AM