intl-tel-input 19.5.5 → 19.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24867,9 +24867,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24867
24867
  return intlTelInputUtils.getValidationError(this._getFullNumber(), t);
24868
24868
  }
24869
24869
  return -99;
24870
- } }, { key: "isValidNumber", value: function() {
24871
- var t = this._getFullNumber();
24872
- return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(t, this.selectedCountryData.iso2) : null;
24870
+ } }, { key: "isValidNumber", value: function(t) {
24871
+ var e = this._getFullNumber();
24872
+ return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(e, this.selectedCountryData.iso2, t) : null;
24873
24873
  } }, { key: "isValidNumberPrecise", value: function() {
24874
24874
  var t = this._getFullNumber();
24875
24875
  return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(t, this.selectedCountryData.iso2) : null;
@@ -24903,7 +24903,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24903
24903
  z(a);
24904
24904
  }
24905
24905
  return null;
24906
- }, S.defaults = K, S.version = "19.5.5", function(a, n) {
24906
+ }, S.defaults = K, S.version = "19.5.6", function(a, n) {
24907
24907
  var t = new Z(a, n);
24908
24908
  return t._init(), a.setAttribute("data-intl-tel-input-id", t.id), window.intlTelInputGlobals.instances[t.id] = t, t;
24909
24909
  };
@@ -24867,9 +24867,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24867
24867
  return intlTelInputUtils.getValidationError(this._getFullNumber(), t);
24868
24868
  }
24869
24869
  return -99;
24870
- } }, { key: "isValidNumber", value: function() {
24871
- var t = this._getFullNumber();
24872
- return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(t, this.selectedCountryData.iso2) : null;
24870
+ } }, { key: "isValidNumber", value: function(t) {
24871
+ var e = this._getFullNumber();
24872
+ return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(e, this.selectedCountryData.iso2, t) : null;
24873
24873
  } }, { key: "isValidNumberPrecise", value: function() {
24874
24874
  var t = this._getFullNumber();
24875
24875
  return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(t, this.selectedCountryData.iso2) : null;
@@ -24903,7 +24903,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24903
24903
  z(a);
24904
24904
  }
24905
24905
  return null;
24906
- }, S.defaults = K, S.version = "19.5.5", function(a, n) {
24906
+ }, S.defaults = K, S.version = "19.5.6", function(a, n) {
24907
24907
  var t = new Z(a, n);
24908
24908
  return t._init(), a.setAttribute("data-intl-tel-input-id", t.id), window.intlTelInputGlobals.instances[t.id] = t, t;
24909
24909
  };
@@ -1860,10 +1860,10 @@ class Iti {
1860
1860
  }
1861
1861
 
1862
1862
  // validate the input val - assumes the global function isPossibleNumber (from utilsScript)
1863
- isValidNumber() {
1863
+ isValidNumber(mobileOnly) {
1864
1864
  const val = this._getFullNumber();
1865
1865
  return window.intlTelInputUtils
1866
- ? intlTelInputUtils.isPossibleNumber(val, this.selectedCountryData.iso2)
1866
+ ? intlTelInputUtils.isPossibleNumber(val, this.selectedCountryData.iso2, mobileOnly)
1867
1867
  : null;
1868
1868
  }
1869
1869
 
package/src/js/utils.js CHANGED
@@ -123,10 +123,17 @@ const isValidNumber = (number, countryCode) => {
123
123
  };
124
124
 
125
125
  // check if given number is possible
126
- const isPossibleNumber = (number, countryCode) => {
126
+ const isPossibleNumber = (number, countryCode, mobileOnly) => {
127
127
  try {
128
128
  const phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();
129
129
  const numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
130
+
131
+ if (mobileOnly) {
132
+ const resultMobile = phoneUtil.isPossibleNumberForTypeWithReason(numberObj, i18n.phonenumbers.PhoneNumberType.MOBILE);
133
+ const isPossibleMobile = resultMobile === i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE;
134
+ return isPossibleMobile;
135
+ }
136
+
130
137
  // can't use phoneUtil.isPossibleNumber directly as it accepts IS_POSSIBLE_LOCAL_ONLY numbers e.g. local numbers that are much shorter
131
138
  const result = phoneUtil.isPossibleNumberWithReason(numberObj);
132
139
  const isPossible = result === i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE;