mirror of
https://github.com/penpot/penpot.git
synced 2025-03-27 23:21:47 -05:00
✨ Add better validation for recent-color change
This commit is contained in:
parent
52fbc678f3
commit
7e302cd21c
3 changed files with 7 additions and 8 deletions
|
@ -13,6 +13,7 @@
|
|||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.schema.desc-native :as smd]
|
||||
[app.common.types.color :as ctc]
|
||||
[app.common.types.colors-list :as ctcl]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
|
@ -166,7 +167,7 @@
|
|||
[:add-recent-color
|
||||
[:map {:title "AddRecentColorChange"}
|
||||
[:type [:= :add-recent-color]]
|
||||
[:color :any]]]
|
||||
[:color ::ctc/recent-color]]]
|
||||
|
||||
[:add-media
|
||||
[:map {:title "AddMediaChange"}
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
[:offset ::sm/safe-number]]]]])
|
||||
|
||||
(sm/def! ::color
|
||||
[:map
|
||||
[:map {:title "Color"}
|
||||
[:id {:optional true} ::sm/uuid]
|
||||
[:name {:optional true} :string]
|
||||
[:path {:optional true} [:maybe :string]]
|
||||
|
@ -83,8 +83,6 @@
|
|||
[:gradient {:optional true} [:maybe ::gradient]]
|
||||
[:image {:optional true} [:maybe ::image-color]]])
|
||||
|
||||
|
||||
;; FIXME: incomplete schema
|
||||
(sm/def! ::recent-color
|
||||
[:and
|
||||
[:map {:title "RecentColor"}
|
||||
|
@ -94,10 +92,10 @@
|
|||
[:image {:optional true} [:maybe ::image-color]]]
|
||||
[::sm/contains-any {:strict true} [:color :gradient :image]]])
|
||||
|
||||
(def color?
|
||||
(def valid-color?
|
||||
(sm/pred-fn ::color))
|
||||
|
||||
(def recent-color?
|
||||
(def valid-recent-color?
|
||||
(sm/pred-fn ::recent-color))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
|
||||
(defn add-recent-color
|
||||
[color]
|
||||
(dm/assert! (ctc/recent-color? color))
|
||||
(dm/assert! (ctc/valid-recent-color? color))
|
||||
(ptk/reify ::add-recent-color
|
||||
ptk/WatchEvent
|
||||
(watch [it _ _]
|
||||
|
@ -143,7 +143,7 @@
|
|||
|
||||
(defn update-color
|
||||
[color file-id]
|
||||
(dm/assert! (ctc/color? color))
|
||||
(dm/assert! (ctc/valid-color? color))
|
||||
(dm/assert! (uuid? file-id))
|
||||
|
||||
(ptk/reify ::update-color
|
||||
|
|
Loading…
Add table
Reference in a new issue