From 3ae0d51082130fbcf5493b3d42fa402fc773f9a0 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 8 Oct 2024 13:49:40 +0200 Subject: [PATCH] Chore: better typing --- src/UI/InputElement/Validators/PhoneValidator.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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() }