check uniqueness
This commit is contained in:
parent
6bb48a42f9
commit
bb4641fc93
|
@ -1,10 +1,15 @@
|
|||
(ns status-im.contacts.validations
|
||||
(:require [cljs.spec :as s]))
|
||||
(:require [cljs.spec :as s]
|
||||
[status-im.persistence.realm :as realm]))
|
||||
|
||||
(s/def ::not-empty-string (s/and string? not-empty))
|
||||
(defn unique-identity? [identity]
|
||||
(println identity)
|
||||
(not (realm/exists? :contacts :whisper-identity identity)))
|
||||
|
||||
(s/def ::name ::not-empty-string)
|
||||
(s/def ::unique-identity unique-identity?)
|
||||
(s/def ::name (s/and ::not-empty-string ::unique-identity))
|
||||
(s/def ::whisper-identity ::not-empty-string)
|
||||
|
||||
(s/def ::contact (s/keys :req-un [::name ::whisper-identity]
|
||||
:opt-un [::phone ::photo-path ::address]))
|
||||
:opt-un [::phone ::photo-path ::address]))
|
||||
|
|
Loading…
Reference in New Issue