Invalid phone number error is shown for valid phone number (#1087)

This commit is contained in:
alwx 2017-05-03 15:56:50 +03:00 committed by Roman Volosovskyi
parent d9ecb20cad
commit 145e3ba1d4
2 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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))))))