@classmethod
  def CanonicalizePhone(cls, phone):
    if not phone:
      raise InvalidRequestError('Phone number cannot be empty.')

    if phone[0] != '+':
      raise InvalidRequestError('Phone number "%s" is not in E.164 format.' % phone)

    try:
      phone_num = phonenumbers.parse(phone)
    except phonenumbers.phonenumberutil.NumberParseException:
      raise InvalidRequestError('"%s" is not a phone number.' % phone)

    if not phonenumbers.is_possible_number(phone_num):
      raise InvalidRequestError('"%s" is not a possible phone number.' % phone)

    return phone
Given an arbitrary string, validates that it is in the expected E.164 phone number
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/identity.py/Identity.CanonicalizePhone