Skip to content

Commit

Permalink
Add invalid value to phone number object if country is not exists in …
Browse files Browse the repository at this point in the history
…filtered list
  • Loading branch information
Chernavskikh authored and Alina Chernavskikh committed Jan 21, 2021
1 parent f8c61ab commit b5f003d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/vue-tel-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,21 @@ export default {
...phoneObject
} = result;
const valid = result.isValid?.();
let valid = result.isValid?.();
let formatted = this.phone;
if (valid) {
formatted = result.format?.(this.parsedMode.toUpperCase());
}
if (result.country && (this.ignoredCountries.length || this.onlyCountries.length)) {
const isCountryInFilteredList = this.filteredCountries.filter(
(obj) => obj.iso2 === result.country,
).length;
if (!isCountryInFilteredList) { valid = false; }
}
Object.assign(phoneObject, {
countryCode: result.country,
valid,
Expand Down

0 comments on commit b5f003d

Please sign in to comment.