diff --git a/src/UI/InputElement/Validators/PhoneValidator.ts b/src/UI/InputElement/Validators/PhoneValidator.ts index 79c16d18b0..12b15870ed 100644 --- a/src/UI/InputElement/Validators/PhoneValidator.ts +++ b/src/UI/InputElement/Validators/PhoneValidator.ts @@ -1,4 +1,4 @@ -import { parsePhoneNumberFromString } from "libphonenumber-js" +import { CountryCode, parsePhoneNumberFromString } from "libphonenumber-js" import { Validator } from "../Validator" import { Translation } from "../../i18n/Translation" import Translations from "../../i18n/Translations" @@ -46,16 +46,16 @@ export default class PhoneValidator extends Validator { if (str.startsWith("tel:")) { str = str.substring("tel:".length) } - let countryCode = undefined + let countryCode: CountryCode = undefined if (country) { - countryCode = country() + countryCode = country()?.toUpperCase() } - if (this.isShortCode(str, countryCode?.toUpperCase())) { + if (this.isShortCode(str, countryCode)) { return str } return parsePhoneNumberFromString( str, - countryCode?.toUpperCase() as any + countryCode )?.formatInternational() }