From 9f758a6f471b609f7db5a9d434a68dbe9f373fb0 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 3 Jul 2023 15:30:59 +0800 Subject: [PATCH] fix: URL type schema validation --- src/main/frontend/handler/property.cljs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/handler/property.cljs b/src/main/frontend/handler/property.cljs index d24b15e8bb..713b768b5c 100644 --- a/src/main/frontend/handler/property.cljs +++ b/src/main/frontend/handler/property.cljs @@ -29,7 +29,9 @@ :number number? :date inst? :boolean boolean? - :url uri? + :url [:fn + {:error/message "should be a URL"} + gp-util/url?] :object uuid?}) ; TODO: make sure block exists ;; schema -> type, cardinality, object's class @@ -82,7 +84,7 @@ (js/Date. v-str) :url - (goog.Uri. v-str))) + v-str)) (defn add-property! [repo block k-name v] @@ -102,8 +104,9 @@ (notification/show! (str e) :error false) nil))] (when-not (contains? (if (set? value) value #{value}) v*) - (if-let [msg (me/humanize (mu/explain-data schema v*))] - (notification/show! msg :error false) + (if-let [msg (me/humanize (mu/explain-data schema v))] + (let [msg' (str "\"" k-name "\"" " " (if (coll? msg) (first msg) msg))] + (notification/show! msg' :warning)) (do ;; FIXME: what if the block already have a block/type, e.g. whiteboard? (when (and property (nil? (:block/type property)))