From 145e3ba1d46bf849e558dd6bfa1cb7b30abcc7bd Mon Sep 17 00:00:00 2001 From: alwx Date: Wed, 3 May 2017 15:56:50 +0300 Subject: [PATCH] Invalid phone number error is shown for valid phone number (#1087) --- src/status_im/chat/handlers/input.cljs | 7 +++---- src/status_im/utils/phone_number.cljs | 8 +++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/status_im/chat/handlers/input.cljs b/src/status_im/chat/handlers/input.cljs index 3c58c482e4..c874886a64 100644 --- a/src/status_im/chat/handlers/input.cljs +++ b/src/status_im/chat/handlers/input.cljs @@ -186,7 +186,7 @@ (handlers/register-handler ::proceed-validation-messages (handlers/side-effect! - (fn [db [_ command chat-id {:keys [markup validationHandler parameters] :as errors} proceed-fn]] + (fn [db [_ command chat-id {:keys [markup validationHandler parameters]} proceed-fn]] (let [set-errors #(do (dispatch [:set-chat-ui-props {:validation-messages % :sending-in-progress? false}]))] (cond @@ -321,9 +321,8 @@ {:command command :chat-id chat-id :data-type :validator - :after #(do - (dispatch [::proceed-validation-messages - command chat-id %2 after-validation]))}]))))) + :after #(dispatch [::proceed-validation-messages + command chat-id %2 after-validation])}]))))) (handlers/register-handler :set-chat-seq-arg-input-text diff --git a/src/status_im/utils/phone_number.cljs b/src/status_im/utils/phone_number.cljs index d97cef559a..488cd784f4 100644 --- a/src/status_im/utils/phone_number.cljs +++ b/src/status_im/utils/phone_number.cljs @@ -23,6 +23,8 @@ (defn valid-mobile-number? [number] (when (string? number) - (let [number-obj (awesome-phonenumber. number country-code)] - (and (.isValid number-obj) - (.isMobile number-obj))))) + (let [{:keys [valid type]} (-> (awesome-phonenumber. number country-code) + (.toJSON) + (js->clj :keywordize-keys true))] + (and valid + (some #{(keyword type)} '(:mobile :fixed-line-or-mobile :pager))))))