check identity length

Former-commit-id: fa2e2c2f28
This commit is contained in:
Roman Volosovskyi 2016-06-22 16:38:50 +03:00
parent cbb56e499c
commit b505a3dc05
1 changed files with 8 additions and 2 deletions

View File

@ -2,14 +2,20 @@
(: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)))
(defn valid-length? [identity]
(= 64 (count identity)))
(s/def ::identity-length valid-length?)
(s/def ::unique-identity unique-identity?)
(s/def ::not-empty-string (s/and string? not-empty))
(s/def ::name ::not-empty-string)
(s/def ::whisper-identity (s/and ::not-empty-string ::unique-identity))
(s/def ::whisper-identity (s/and ::not-empty-string
::unique-identity
::identity-length))
(s/def ::contact (s/keys :req-un [::name ::whisper-identity]
:opt-un [::phone ::photo-path ::address]))