From e07ada5ad4536366aeb9c0f52bc172324c6774ef Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 29 Dec 2015 23:40:01 +0200 Subject: [PATCH] Add validation for shapes. --- frontend/uxbox/data/workspace.cljs | 3 +-- frontend/uxbox/schema.cljs | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/uxbox/data/workspace.cljs b/frontend/uxbox/data/workspace.cljs index 741b64edb..0eb6635ac 100644 --- a/frontend/uxbox/data/workspace.cljs +++ b/frontend/uxbox/data/workspace.cljs @@ -91,11 +91,10 @@ (-apply-update [_ state] (assoc-in state [:workspace :selected] #{})))) -;; TODO: validate shape - (defn add-shape "Mark a shape selected for drawing in the canvas." [shape props] + (sc/validate! +shape-schema+ shape) (sc/validate! +shape-props-schema+ props) (reify rs/UpdateEvent diff --git a/frontend/uxbox/schema.cljs b/frontend/uxbox/schema.cljs index 2ce54c44a..d9f355e4e 100644 --- a/frontend/uxbox/schema.cljs +++ b/frontend/uxbox/schema.cljs @@ -1,7 +1,8 @@ (ns uxbox.schema - (:refer-clojure :exclude [keyword uuid]) + (:refer-clojure :exclude [keyword uuid vector]) (:require [bouncer.core :as b] - [bouncer.validators :as v])) + [bouncer.validators :as v] + [uxbox.shapes :refer (shape?)])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Validators