is there a way to use Malli to remove nil
values in a map? :thinking_face:
The oddest thing. I have two projects. Both use malli 0.2.1 (according to `lein deps :tree`). But one of them accepts the syntax `[:map [:a string?] [:b string?]]` just fine, while the other throws an error on `(restart)`:
data-spec collection [] should be homogeneous, 3 values found
Any idea what could be the cause?@lkorogodski Can you try with lein clean
and then run your project again?
You might have some left-overs in your target folder or something
Same result.
@lkorogodski Please don't paste such long output into slack but rather use something like github gist
What happens when you do:
(require '[<http://clojure.java.io|clojure.java.io> :as io])
(io/resource "malli/core__init.class")
just checking if this isn't an AOT-related problem
Ok, sorry. Just a moment.
nREPL server started on port 64815 on host 127.0.0.1 - <nrepl://127.0.0.1:64815>
Connecting to local nREPL server...
Clojure 1.10.3
(require '[<http://clojure.java.io|clojure.java.io> :as io])
=> nil
(io/resource "malli/core__init.class")
=> nil
(require '[malli.core :as m])
=> nil
(m/validator [:map [:a string?] [:b string?]])
=>
#object[malli.core$_map_schema$reify$reify__21001$fn__21022
0x5361e937
"malli.core$_map_schema$reify$reify__21001$fn__21022@5361e937"]
That seems to work. But when I call (restart)
, it fails.
The usage for the router is as follows:
["/my-route" {:get {:summary "..."
:parameters {:header {:authorization string?}
:query [:map
[:a string?]
[:b string?]}
;; other things
}}]
map?
works in place of [:map ...]
but doesn't check enough, of course.