This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-23
Channels
- # adventofcode (21)
- # announcements (4)
- # babashka (35)
- # beginners (36)
- # calva (76)
- # cider (16)
- # clj-kondo (24)
- # clj-on-windows (12)
- # clojure (70)
- # clojure-europe (7)
- # clojure-nl (13)
- # clojure-spec (3)
- # clojure-uk (3)
- # clojurescript (34)
- # conjure (11)
- # cursive (22)
- # datomic (30)
- # deps-new (2)
- # emacs (36)
- # fulcro (28)
- # gratitude (4)
- # honeysql (16)
- # hugsql (8)
- # introduce-yourself (6)
- # jobs (1)
- # malli (4)
- # missionary (6)
- # off-topic (129)
- # other-languages (34)
- # polylith (3)
- # reagent (9)
- # reitit (27)
- # releases (13)
- # remote-jobs (1)
- # reveal (1)
- # shadow-cljs (2)
- # tools-build (3)
- # tools-deps (18)
- # web-security (7)
- # xtdb (4)
#re-frame has the function ->interceptor
which has a parameter list of [& {:as m :keys [id before after]}]
, which uses this new feature: https://clojure.org/news/2021/03/18/apis-serving-people-and-programs. how can i represent this in a malli function schema?
i have cobbled together this, but it feels pretty hacky, lol:
(m/=> ->interceptor
[:=>
[:cat
[:or
[:and
[:map
[:id qualified-keyword?]
[:before {:optional true} fn?]
[:after {:optional true} fn?]]
[:fn (fn [{:keys [before after]}] (or before after))]]
[:and [:catn
[:id [:cat [:= :id] qualified-keyword?]]
[:before [:? [:cat [:= :before] fn?]]]
[:after [:? [:cat [:= :after] fn?]]]]
[:fn (fn [[_ & args]] (pos? (count args)))]]]]
:any])
is there a way to make generative testing work with defn schemas like this? (mi/check)
reports there’s no generator attached to this schema
Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:137).
:malli.generator/no-generator {:options {:malli.core/function-checker #function[malli.generator/function-checker], :malli.generator/recursion {[:and [:map [:id qualified-keyword?] [:before {:optional true} fn?] [:after {:optional true} fn?]] [:fn #function[executor.interceptor/eval70188/fn--70190]]] 1, [:map [:id qualified-keyword?] [:before {:optional true} fn?] [:after {:optional true} fn?]] 1}}, :schema fn?}