This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-10
Channels
- # announcements (1)
- # babashka (18)
- # beginners (122)
- # calva (18)
- # cider (3)
- # cljs-dev (2)
- # cljsrn (3)
- # clojure (102)
- # clojure-europe (15)
- # clojure-france (2)
- # clojure-nl (1)
- # clojure-portugal (1)
- # clojure-spec (3)
- # clojure-uk (8)
- # clojurescript (46)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (2)
- # cursive (15)
- # datalog (13)
- # datomic (18)
- # emacs (4)
- # fulcro (8)
- # helix (8)
- # instaparse (1)
- # introduce-yourself (2)
- # jobs (4)
- # leiningen (23)
- # lsp (26)
- # malli (21)
- # off-topic (34)
- # pedestal (21)
- # polylith (6)
- # reitit (5)
- # remote-jobs (3)
- # schema (1)
- # sci (8)
- # shadow-cljs (8)
- # spacemacs (3)
- # sql (30)
- # testing (31)
- # tools-deps (21)
- # vim (25)
- # xtdb (8)
I would think ':b' could be in square brackets: [:a {:x "s"} [:b]], but it doesn't work, i'd like to be able to nest :cat/n
(-> [:cat
[:enum :a]
[:map [:x string?]]
[:cat [:enum :b]]]
(mc/explain
[:a {:x "s"} :b])
(me/humanize))
@joel380 from the README:
As all these examples show, the "seqex" operators take any non-seqex child schema to mean a sequence of one element that matches that schema. To force that behaviour for a seqex child :schema can be used:
(m/validate
[:cat [:= :names] [:schema [:* string?]] [:= :nums] [:schema [:* number?]]]
[:names ["a" "b"] :nums [1 2 3]])
; => true
;; whereas
(m/validate
[:cat [:= :names] [:* string?] [:= :nums] [:* number?]]
[:names "a" "b" :nums 1 2 3])
; => true
@emccue fixed in master. Also, you don鈥檛 need the malli.instrument/collect!
, malli.dev/start!
calls that.
currently only on start!
. I tried to add var-watching to the once-registered vars, but didn't have the skills to do that. start!
& stop!
should play nice with reloaded repl thou.
Question, is it possible to add sci
options on a custom decoder, or any ability to set sci options globally?
Hi! How can I check if x satisfies the protocol y in malli metadata schema?
Ok I found the answer!
I found this thread via Slack search. Please share the answer!!
Create a schema from a -simple-schema
(def proto-schema (-simple-schema {:pred (fn [x] (satisfies? PROTO x)}))
Thank you! Will try this. :thumbsup:
currently only on start!
. I tried to add var-watching to the once-registered vars, but didn't have the skills to do that. start!
& stop!
should play nice with reloaded repl thou.
silly-hacky-var-watching-diy-horror:
(defn plus1
"adds 1 to number"
{:malli/schma [:=> [:cat :int] :int]}
[x] (inc x))
(add-watch #'plus1 ::watch (fn [_ v _ _] (future (println v "=>" (-> v meta :malli/schema)))))
(defn plus1
"adds 1 to number"
{:malli/schema [:=> [:cat [:int {:min 0}]] :int]}
[x] (inc x))
; =prints=> #'user/plus1 => [:=> [:cat [:int {:min 0}]] :int]
if that could be made robust, could just re-define schmatized vars and the clj-kondo + instrumentation would follow instantly.