From b505a3dc057bf899569270c9f5004fcae85a8c33 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Wed, 22 Jun 2016 16:38:50 +0300 Subject: [PATCH] check identity length Former-commit-id: fa2e2c2f28f95160b252f0e78e9de55dc7462fa7 --- src/status_im/contacts/validations.cljs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/status_im/contacts/validations.cljs b/src/status_im/contacts/validations.cljs index 9747fe9fb3..ca3feee759 100644 --- a/src/status_im/contacts/validations.cljs +++ b/src/status_im/contacts/validations.cljs @@ -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]))