diff --git a/.changeset/green-icons-tease.md b/.changeset/green-icons-tease.md new file mode 100644 index 00000000..a59df88e --- /dev/null +++ b/.changeset/green-icons-tease.md @@ -0,0 +1,5 @@ +--- +"@razorpay/i18nify-js": patch +--- + +fix: text should be treated inValid in isValidPhoneNumber [ATLAS-196] diff --git a/packages/i18nify-js/src/modules/phoneNumber/isValidPhoneNumber.ts b/packages/i18nify-js/src/modules/phoneNumber/isValidPhoneNumber.ts index 6bd17587..efcb3afe 100644 --- a/packages/i18nify-js/src/modules/phoneNumber/isValidPhoneNumber.ts +++ b/packages/i18nify-js/src/modules/phoneNumber/isValidPhoneNumber.ts @@ -10,6 +10,7 @@ const isValidPhoneNumber = ( ): boolean => { // Clean the provided phoneNumber by removing non-numeric characters const cleanedPhoneNumber = cleanPhoneNumber(phoneNumber.toString()); + if (!cleanedPhoneNumber) return false; const regexMapper = PHONE_REGEX_MAPPER; // Detect or validate the country code