Skip to content

Commit

Permalink
Fix: isValidNumber returning false for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Aug 7, 2024
1 parent e04b42c commit b550e01
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 48 deletions.
2 changes: 2 additions & 0 deletions build/js/intlTelInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@ declare module "intl-tel-input" {
getSelectedCountryData(): SelectedCountryData;
getValidationError(): number;
isValidNumber(): boolean | null;
private _utilsIsPossibleNumber;
isValidNumberPrecise(): boolean | null;
private _utilsIsValidNumber;
setCountry(iso2: string): void;
setNumber(number: string): void;
setPlaceholderNumberType(type: NumberType): void;
Expand Down
22 changes: 18 additions & 4 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2740,17 +2740,31 @@ var factoryOutput = (() => {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInput.min.js

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions build/js/intlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2739,17 +2739,31 @@ var factoryOutput = (() => {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.min.js

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions react/build/IntlTelInput.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2735,17 +2735,31 @@ var Iti = class {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
2 changes: 2 additions & 0 deletions react/build/IntlTelInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@ declare module "intl-tel-input" {
getSelectedCountryData(): SelectedCountryData;
getValidationError(): number;
isValidNumber(): boolean | null;
private _utilsIsPossibleNumber;
isValidNumberPrecise(): boolean | null;
private _utilsIsValidNumber;
setCountry(iso2: string): void;
setNumber(number: string): void;
setPlaceholderNumberType(type: NumberType): void;
Expand Down
22 changes: 18 additions & 4 deletions react/build/IntlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2699,17 +2699,31 @@ var Iti = class {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/build/IntlTelInputWithUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2735,17 +2735,31 @@ var Iti = class {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/build/IntlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2699,17 +2699,31 @@ var Iti = class {
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/demo/set-number-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26228,17 +26228,31 @@
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/demo/simple-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26228,17 +26228,31 @@
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/demo/toggle-disabled-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26228,17 +26228,31 @@
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
22 changes: 18 additions & 4 deletions react/demo/validation-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26228,17 +26228,31 @@
//* Validate the input val
isValidNumber() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
const isValid = this._utilsIsPossibleNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsPossibleNumber(val);
}
_utilsIsPossibleNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
}
//* Validate the input val (precise)
isValidNumberPrecise() {
const val = this._getFullNumber();
if (/\p{L}/u.test(val)) {
return false;
const alphaCharPosition = val.search(/\p{L}/u);
if (alphaCharPosition > -1) {
const beforeAlphaChar = val.substring(0, alphaCharPosition);
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
const isValid = this._utilsIsValidNumber(val);
return beforeAlphaIsValid && isValid;
}
return this._utilsIsValidNumber(val);
}
_utilsIsValidNumber(val) {
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
}
//* Update the selected country, and update the input val accordingly.
Expand Down
Loading

0 comments on commit b550e01

Please sign in to comment.