mirror of
https://github.com/penpot/penpot.git
synced 2025-03-18 10:41:29 -05:00
🐛 Add schema validation for color changes
This commit is contained in:
parent
ef3a47b492
commit
1f53e48032
3 changed files with 19 additions and 9 deletions
|
@ -176,12 +176,12 @@
|
|||
[:add-color
|
||||
[:map {:title "AddColorChange"}
|
||||
[:type [:= :add-color]]
|
||||
[:color :any]]]
|
||||
[:color ::ctc/color]]]
|
||||
|
||||
[:mod-color
|
||||
[:map {:title "ModColorChange"}
|
||||
[:type [:= :mod-color]]
|
||||
[:color :any]]]
|
||||
[:color ::ctc/color]]]
|
||||
|
||||
[:del-color
|
||||
[:map {:title "DelColorChange"}
|
||||
|
@ -608,8 +608,7 @@
|
|||
(when (and (= object-type :shape) (nil? page-id))
|
||||
(ex/raise :type :internal :hint "update for shapes needs a page-id"))
|
||||
|
||||
(letfn [(update-fn
|
||||
[data]
|
||||
(letfn [(update-fn [data]
|
||||
(if (some? value)
|
||||
(assoc-in data [:plugin-data namespace key] value)
|
||||
(update-in data [:plugin-data namespace] (fnil dissoc {}) key)))]
|
||||
|
|
|
@ -895,11 +895,11 @@
|
|||
:description "Satisfies Inst protocol"
|
||||
:error/message "should be an instant"
|
||||
:gen/gen (->> (sg/small-int)
|
||||
(sg/fmap (fn [v] (tm/instant v))))
|
||||
(sg/fmap (fn [v] (tm/parse-instant v))))
|
||||
|
||||
:decode/string tm/instant
|
||||
:decode/string tm/parse-instant
|
||||
:encode/string tm/format-instant
|
||||
:decode/json tm/instant
|
||||
:decode/json tm/parse-instant
|
||||
:encode/json tm/format-instant
|
||||
::oapi/type "string"
|
||||
::oapi/format "iso"}})
|
||||
|
|
|
@ -27,11 +27,22 @@
|
|||
#?(:clj (Instant/now)
|
||||
:cljs (.local ^js DateTime)))
|
||||
|
||||
(defn instant
|
||||
(defn instant?
|
||||
[o]
|
||||
#?(:clj (instance? Instant o)
|
||||
:cljs (instance? DateTime o)))
|
||||
|
||||
(defn parse-instant
|
||||
[s]
|
||||
(if (int? s)
|
||||
(cond
|
||||
(instant? s)
|
||||
s
|
||||
|
||||
(int? s)
|
||||
#?(:clj (Instant/ofEpochMilli s)
|
||||
:cljs (.fromMillis ^js DateTime s #js {:zone "local" :setZone false}))
|
||||
|
||||
(string? s)
|
||||
#?(:clj (Instant/parse s)
|
||||
:cljs (.fromISO ^js DateTime s))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue