2016-09-27 14:00:43 +00:00
|
|
|
(ns status-im.new-group.validations
|
2017-07-04 17:53:49 +00:00
|
|
|
(:require [cljs.spec.alpha :as s]
|
2016-09-27 14:00:43 +00:00
|
|
|
[status-im.utils.phone-number :refer [valid-mobile-number?]]
|
|
|
|
[status-im.constants :refer [console-chat-id wallet-chat-id]]
|
2016-10-14 06:44:38 +00:00
|
|
|
[clojure.string :as str]
|
|
|
|
[status-im.utils.homoglyph :as h]))
|
2016-09-27 14:00:43 +00:00
|
|
|
|
|
|
|
(defn not-illegal-name? [username]
|
|
|
|
(let [username (some-> username (str/trim))]
|
2016-10-14 06:44:38 +00:00
|
|
|
(and (not (h/matches username console-chat-id))
|
|
|
|
(not (h/matches username wallet-chat-id)))))
|
2016-09-27 14:00:43 +00:00
|
|
|
|
|
|
|
(s/def ::not-empty-string (s/and string? not-empty))
|
|
|
|
(s/def ::not-illegal-name not-illegal-name?)
|
|
|
|
|
|
|
|
(s/def ::name (s/and ::not-empty-string
|
2016-10-14 06:44:38 +00:00
|
|
|
::not-illegal-name))
|
2017-02-07 10:56:39 +00:00
|
|
|
|
|
|
|
(s/def ::topic (s/and ::not-empty-string
|
|
|
|
::not-illegal-name
|
|
|
|
(partial re-matches #"[a-z0-9\-]+")))
|