This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-12
Channels
- # babashka (6)
- # beginners (23)
- # calva (27)
- # cider (1)
- # clj-kondo (23)
- # cljsrn (2)
- # clojars (4)
- # clojure (90)
- # clojure-dev (8)
- # clojure-europe (1)
- # clojure-serbia (1)
- # clojure-spec (2)
- # clojurescript (9)
- # code-reviews (7)
- # core-async (1)
- # cursive (4)
- # datomic (13)
- # emacs (2)
- # hoplon (28)
- # juxt (12)
- # leiningen (1)
- # malli (22)
- # nrepl (3)
- # off-topic (51)
- # reitit (8)
- # shadow-cljs (16)
- # spacemacs (25)
- # sql (4)
- # test-check (5)
- # tools-deps (5)
About to replace MermaidJS with DOT, because it just works: https://github.com/metosin/malli/pull/219
the whole transformer is 69 loc, with most code reusable and could be part of malli.util
(collecting and resolving references).
Hi I am new to malli Can I use multi with recursive ? I tried this and it does not work
(def map-multi-recursive
[:map
{:registry
{::filter
[:multi
{:dispatch :type}
["in" [:map [:type [:= "in"]] [:value [:vector [:ref ::filter]]]]]
["or" [:map [:type [:= "or"]] [:value [:vector [:ref ::filter]]]]]
["not" [:map [:type [:= "not"]] [:value [:ref ::filter]]]]
["in" [:map [:type [:= "in"]] [:value [:map
[:dimensions dimension]
[:values [:vector string?]]]]]]]}}
:filter ::filter])
@shmuel.buchnic I believe the map entry should be [:filter ::filter]
, e.g. surround with brackets
@U055NJ5CC thanks for the fast response I tried and it still return an invalid schema . I will try to narrow down the issue .
@U055NJ5CC well it is working with simple validate , but trying to use it as :coercion to body parameters and it fails .
will fail-fast in master: https://github.com/metosin/malli/commit/5d54e6b285c3ce440f1310302bdc2ba20a84d508
(m/schema
[:map
{:registry
{::filter
[:multi
{:dispatch :type}
["in" [:map [:type [:= "in"]] [:value [:vector [:ref ::filter]]]]]
["or" [:map [:type [:= "or"]] [:value [:vector [:ref ::filter]]]]]
["not" [:map [:type [:= "not"]] [:value [:ref ::filter]]]]
["in" [:map [:type [:= "in"]] [:value [:map
[:dimensions [:tuple int? int?]]
[:values [:vector string?]]]]]]]}}
[:filter ::filter]])
; => Throws :malli.core/non-distinct-entry-keys {:keys ("in" "or" "not" "in")}
I fixed that the updated looks like this :
(def filter-local-registry
{:registry
{::filter
[:multi
{:dispatch :type}
["and" [:map [:type [:= "and"]] [:value [:vector [:ref ::filter]]]]]
["or" [:map [:type [:= "or"]] [:value [:vector [:ref ::filter]]]]]
["not" [:map [:type [:= "not"]] [:value [:ref ::filter]]]]
["in" [:map [:type [:= "in"]] [:value [:map
[:dimension dimension]
[:values [:vector string?]]]]]]]}})
no 😞 I fixed it before u wrote forgot to update. validate call is working
but as :coercion it does not work
0.5.3 I debug it . It looks like at first he find filter in registry (holds 2 the default one and the local) But on later call I only see the default on the registry and than lookup fail .
Narrowing issue : This is the schema
(def sample-request
[:map {:registry {::age [:and int? [:> 18]]}}
[:age ::age]])
This is the route
(def overview
["/api/v1/overview"
{:swagger {:tags ["Overview"]}
:post {:summary "get an overview data"
:parameters {:body sample-request}
:handler get-overview-data
}}])
The handler and other are just like in :
https://github.com/metosin/reitit/blob/master/examples/ring-malli-swagger/src/example/server.clj
So it is not related to recursive or mutli I guess it is just wrong usage of me with registry I just did not find out what it is 😞