malli

https://github.com/metosin/malli :malli:
schmee 2021-04-16T17:35:08.442900Z

is there a way to use Malli to remove nil values in a map? :thinking_face:

Leonid Korogodski 2021-04-16T20:34:31.443600Z

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?

borkdude 2021-04-16T20:35:18.444Z

@lkorogodski Can you try with lein clean and then run your project again?

borkdude 2021-04-16T20:35:33.444600Z

You might have some left-overs in your target folder or something

Leonid Korogodski 2021-04-16T20:36:42.444800Z

Same result.

borkdude 2021-04-16T20:57:06.445900Z

@lkorogodski Please don't paste such long output into slack but rather use something like github gist

borkdude 2021-04-16T20:57:56.446400Z

What happens when you do:

(require '[<http://clojure.java.io|clojure.java.io> :as io])
(io/resource "malli/core__init.class")

borkdude 2021-04-16T20:58:07.446700Z

just checking if this isn't an AOT-related problem

Leonid Korogodski 2021-04-16T22:21:58.447700Z

Ok, sorry. Just a moment.

Leonid Korogodski 2021-04-16T22:27:32.450100Z

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])
=&gt; nil
(io/resource "malli/core__init.class")
=&gt; nil
(require '[malli.core :as m])
=&gt; nil
(m/validator [:map [:a string?] [:b string?]])
=&gt;
#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
                   }}]

Leonid Korogodski 2021-04-16T22:33:59.451200Z

map? works in place of [:map ...] but doesn't check enough, of course.