intl-tel-input 19.5.4 → 19.5.5

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.
@@ -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.4", function(a, n) {
24906
+ }, S.defaults = K, S.version = "19.5.5", 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
  };
@@ -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.4", function(a, n) {
24906
+ }, S.defaults = K, S.version = "19.5.5", 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
  };
package/src/js/utils.js CHANGED
@@ -129,7 +129,17 @@ const isPossibleNumber = (number, countryCode) => {
129
129
  const numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
130
130
  // can't use phoneUtil.isPossibleNumber directly as it accepts IS_POSSIBLE_LOCAL_ONLY numbers e.g. local numbers that are much shorter
131
131
  const result = phoneUtil.isPossibleNumberWithReason(numberObj);
132
- return result === i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE;
132
+ const isPossible = result === i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE;
133
+
134
+ // custom validation for UK mobile numbers
135
+ // because libphonenumber returns IS_POSSIBLE (rather than IS_POSSIBLE_LOCAL_ONLY) for 0740012 which is not possible
136
+ let customValidation = true;
137
+ const nationalNumber = numberObj.getNationalNumber().toString();
138
+ if (countryCode === 'gb' && nationalNumber.charAt(0) === '7') {
139
+ customValidation = nationalNumber.length === 10;
140
+ }
141
+
142
+ return isPossible && customValidation;
133
143
  } catch (e) {
134
144
  return false;
135
145
  }
@@ -34,10 +34,9 @@ describe("isValidNumber:", function() {
34
34
  expect(iti.isValidNumber()).toBeFalsy();
35
35
  });
36
36
 
37
- // guess this is a quirk of UK phone numbers that some valid ones are only 10 digits (e.g. 0773312345)
38
- it("returns true for: invalid (too short by 1 digit) intl number", function() {
37
+ it("returns false for: invalid (too short by 1 digit) intl number", function() {
39
38
  iti.setNumber("+44 7733 12345");
40
- expect(iti.isValidNumber()).toBeTruthy();
39
+ expect(iti.isValidNumber()).toBeFalsy();
41
40
  });
42
41
 
43
42
  it("returns false for: invalid (too long) intl number", function() {