From 55849ce68e2ebbd977e0d3024f97e6b2dcecf5d0 Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Wed, 28 Sep 2016 17:10:48 +0300 Subject: [PATCH] extended phone number validation (#259) --- src/status_im/chat/views/new_message.cljs | 1 - src/status_im/profile/validations.cljs | 1 - src/status_im/utils/phone_number.cljs | 6 ++++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/status_im/chat/views/new_message.cljs b/src/status_im/chat/views/new_message.cljs index f59ff230b1..01308d0d98 100644 --- a/src/status_im/chat/views/new_message.cljs +++ b/src/status_im/chat/views/new_message.cljs @@ -5,7 +5,6 @@ [status-im.components.react :refer [view]] [status-im.chat.views.message-input :refer [plain-message-input-view]] [status-im.chat.views.staged-command :refer [simple-command-staged-view]] - [status-im.utils.phone-number :refer [valid-mobile-number?]] [status-im.utils.platform :refer [platform-specific]] [status-im.chat.styles.message :as st])) diff --git a/src/status_im/profile/validations.cljs b/src/status_im/profile/validations.cljs index 74a8787303..78882ebc71 100644 --- a/src/status_im/profile/validations.cljs +++ b/src/status_im/profile/validations.cljs @@ -1,6 +1,5 @@ (ns status-im.profile.validations (:require [cljs.spec :as s] - [status-im.utils.phone-number :refer [valid-mobile-number?]] [status-im.constants :refer [console-chat-id wallet-chat-id]] [clojure.string :as str])) diff --git a/src/status_im/utils/phone_number.cljs b/src/status_im/utils/phone_number.cljs index da0ada6733..ce0aac69a2 100644 --- a/src/status_im/utils/phone_number.cljs +++ b/src/status_im/utils/phone_number.cljs @@ -12,6 +12,8 @@ (defn valid-mobile-number? [number] (when (string? number) - (let [number-obj (awesome-phonenumber. number country-code "international")] - (and (.isValid number-obj) + (let [pattern #"^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{2})[-. ]*(\d{2})\s*$" + number-obj (awesome-phonenumber. number country-code "international")] + (and (re-matches pattern number) + (.isValid number-obj) (.isMobile number-obj)))))