4

I am using this library https://github.com/me2day/libPhoneNumber-iOS for validating the phone numbers.

I want to ask is that on whatsapp If you enter a phone number digits greater or less than the original Phone number of some country it shows error and give you a message that the digits are less than or greater than. How can I do this? how can I figure out the number of digits in phone number used in particular country and gives error according to that.

At the moment I am validating the phone number of country like this

let phoneUtil = NBPhoneNumberUtil.sharedInstance()

do {
    let number:NBPhoneNumber = try phoneUtil.parse(phoneNumber, defaultRegion:countryCode)

    let isValidNumber: Bool = phoneUtil.isValidNumberForRegion(number, regionCode: countryCode)

    return isValidNumber
}catch  let error as NSError {
    print(error.localizedDescription)
    return false
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
user1hjgjhgjhggjhg
  • 1,237
  • 4
  • 15
  • 34
  • To "_figure out the number of digits in phone number used in particular country_", you may need to take a look at [E.164 : The international public telecommunication numbering plan](https://www.itu.int/rec/T-REC-E.164/en). Eventually the table from http://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.164C-2011-PDF-E.pdf – Cœur Oct 29 '18 at 05:02

0 Answers0