mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 18:38:22 +02:00
📎 Add minor improvement on notification message validation
This commit is contained in:
parent
9e0fb44b3f
commit
7e50ab52b9
1 changed files with 29 additions and 28 deletions
|
@ -17,9 +17,7 @@
|
||||||
|
|
||||||
(def default-timeout 7000)
|
(def default-timeout 7000)
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private schema:message
|
||||||
schema:message
|
|
||||||
(sm/define
|
|
||||||
[:map {:title "Message"}
|
[:map {:title "Message"}
|
||||||
[:type [::sm/one-of #{:success :error :info :warning}]]
|
[:type [::sm/one-of #{:success :error :info :warning}]]
|
||||||
[:status {:optional true}
|
[:status {:optional true}
|
||||||
|
@ -43,13 +41,16 @@
|
||||||
[:vector
|
[:vector
|
||||||
[:map
|
[:map
|
||||||
[:label :string]
|
[:label :string]
|
||||||
[:callback ::sm/fn]]]]]))
|
[:callback ::sm/fn]]]]])
|
||||||
|
|
||||||
|
(def ^:private valid-message?
|
||||||
|
(sm/validator schema:message))
|
||||||
|
|
||||||
(defn show
|
(defn show
|
||||||
[data]
|
[data]
|
||||||
(dm/assert!
|
(dm/assert!
|
||||||
"expected valid message map"
|
"expected valid message map"
|
||||||
(sm/check! schema:message data))
|
(valid-message? data))
|
||||||
|
|
||||||
(ptk/reify ::show
|
(ptk/reify ::show
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue