code: function getError(number, countryCode) {
      try {
          var phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();
          var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
          return phoneUtil.isPossibleNumberWithReason(numberObj);
      } catch (e) {
          //console.log(e);
  
          // here I convert thrown errors into ValidationResult enums (if possible)
          if (e == i18n.phonenumbers.Error.INVALID_COUNTRY_CODE) {
              return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
          }
          if (e == i18n.phonenumbers.Error.NOT_A_NUMBER) {
              return 4;
          }
          if (e == i18n.phonenumbers.Error.TOO_SHORT_AFTER_IDD || e == i18n.phonenumbers.Error.TOO_SHORT_NSN) {
              return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.TOO_SHORT;
          }
          if (e == i18n.phonenumbers.Error.TOO_LONG) {
              return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.TOO_LONG;
          }
  
          // broken
          return -99;
      }
  }
docs: get more info if the validation has failed e.g. too long/too short