From 5083738c3ff235da7602db99a79a1286bc921b83 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Thu, 25 Apr 2024 11:54:27 +0530 Subject: [PATCH] fix: text should be treated inValid in isValidPhoneNumber [ATLAS-196] (#127) * [fix]: text should be treated inValid * Create green-icons-tease.md --------- Co-authored-by: Tarun Khanna --- .changeset/green-icons-tease.md | 5 +++++ .../i18nify-js/src/modules/phoneNumber/isValidPhoneNumber.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/green-icons-tease.md 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