intl-tel-input 19.5.4 → 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.
- package/README.md +10 -8
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput-jquery.js +4 -4
- package/build/js/intlTelInput-jquery.min.js +2 -2
- package/build/js/intlTelInput.js +4 -4
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/utils.js +28 -28
- package/composer.json +1 -1
- package/package.json +1 -1
- package/react/build/IntlTelInput.cjs.js +1 -1
- package/react/build/IntlTelInput.cjs.js.map +3 -3
- package/react/build/IntlTelInput.esm.js +1 -1
- package/react/build/IntlTelInput.esm.js.map +3 -3
- package/react/demo/simple-bundle.js +4 -4
- package/react/demo/validation-bundle.js +4 -4
- package/src/js/intlTelInput.js +2 -2
- package/src/js/utils.js +19 -2
- package/src/spec/tests/methods/isValidNumber.js +2 -3
|
@@ -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
|
|
24872
|
-
return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(
|
|
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.
|
|
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
|
|
24872
|
-
return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(
|
|
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.
|
|
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
|
};
|
package/src/js/intlTelInput.js
CHANGED
|
@@ -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,13 +123,30 @@ 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;
|
|
140
|
+
|
|
141
|
+
// custom validation for UK mobile numbers
|
|
142
|
+
// because libphonenumber returns IS_POSSIBLE (rather than IS_POSSIBLE_LOCAL_ONLY) for 0740012 which is not possible
|
|
143
|
+
let customValidation = true;
|
|
144
|
+
const nationalNumber = numberObj.getNationalNumber().toString();
|
|
145
|
+
if (countryCode === 'gb' && nationalNumber.charAt(0) === '7') {
|
|
146
|
+
customValidation = nationalNumber.length === 10;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return isPossible && customValidation;
|
|
133
150
|
} catch (e) {
|
|
134
151
|
return false;
|
|
135
152
|
}
|
|
@@ -34,10 +34,9 @@ describe("isValidNumber:", function() {
|
|
|
34
34
|
expect(iti.isValidNumber()).toBeFalsy();
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
|
|
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()).
|
|
39
|
+
expect(iti.isValidNumber()).toBeFalsy();
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
it("returns false for: invalid (too long) intl number", function() {
|