mirror of
https://github.com/status-im/status-react.git
synced 2025-01-12 03:54:32 +00:00
components, profile: better username validation #685
This commit is contained in:
parent
3868e6d3c6
commit
065a0ddc80
@ -71,9 +71,9 @@
|
|||||||
:editable true
|
:editable true
|
||||||
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
|
:input-style (st/name-input-text (s/valid? ::v/name (or new-name name)))
|
||||||
:wrapper-style st/name-input-wrapper
|
:wrapper-style st/name-input-wrapper
|
||||||
:value name
|
:value (or new-name name)
|
||||||
:on-change-text #(dispatch [:set-in [:profile-edit :name] %])
|
:on-change-text #(dispatch [:set-in [:profile-edit :name] %])
|
||||||
:on-end-editing #(when (and new-name (not (str/blank? new-name)))
|
:on-end-editing #(when (s/valid? ::v/name new-name)
|
||||||
(dispatch [:account-update {:name (clean-text new-name)}]))}]]
|
(dispatch [:account-update {:name (clean-text new-name)}]))}]]
|
||||||
[view st/status-container
|
[view st/status-container
|
||||||
(if @status-edit?
|
(if @status-edit?
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
(ns status-im.profile.validations
|
(ns status-im.profile.validations
|
||||||
(:require [cljs.spec :as s]
|
(:require [cljs.spec :as s]
|
||||||
[status-im.constants :refer [console-chat-id wallet-chat-id]]
|
[status-im.constants :refer [console-chat-id wallet-chat-id]]
|
||||||
|
[status-im.chat.constants :as chat-consts]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[status-im.utils.homoglyph :as h]))
|
[status-im.utils.homoglyph :as h]))
|
||||||
|
|
||||||
(defn correct-name? [username]
|
(defn correct-name? [username]
|
||||||
(let [username (some-> username (str/trim))]
|
(let [username (some-> username (str/trim))]
|
||||||
(and (not (h/matches username console-chat-id))
|
(every? false?
|
||||||
(not (h/matches username wallet-chat-id)))))
|
[(str/blank? username)
|
||||||
|
(h/matches username console-chat-id)
|
||||||
|
(h/matches username wallet-chat-id)
|
||||||
|
(str/includes? username chat-consts/command-char)])))
|
||||||
|
|
||||||
(defn correct-email? [email]
|
(defn correct-email? [email]
|
||||||
(let [pattern #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"]
|
(let [pattern #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user