title: Phone number validation and formatting on iOS
body: <p>I am using this library <a href="https://github.com/me2day/libPhoneNumber-iOS" rel="nofollow noreferrer">https://github.com/me2day/libPhoneNumber-iOS</a> for validating the phone numbers. </p>
  
  <p>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.</p>
  
  <p>At the moment I am validating the phone number of country like this</p>
  
  <pre><code>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
  }
  </code></pre>