Fork me on GitHub
#malli
<
2021-08-24
>
Akiz14:08:37

Hi, do you know what is happening here? bq2pg.config> (m/validator [:map [:export? boolean?] [:import? boolean?] [:gcs-name string?]])

#function[malli.core/-map-schema/reify/reify--9403/fn--9419]
But using > 3 elements fails… bq2pg.config> (m/validator [:map [:export? boolean?] [:import? boolean?] [:gcs-name string?] [:extra string?]])
Execution error (NoClassDefFoundError) at malli.impl.util/f (util.cljc:54).
malli/impl/util$f__7020__7021$fn__7045

Akiz14:08:24

@zikajk This happens only when I use malli.clj-kondo +

(-> (mc/collect *ns*) (mc/linter-config))
(mc/emit!)
(md/start!)
after some time… I can not reproduce it well enough 😞

niclasnilsson21:08:09

I’m trying out the instrumentation, and I’m probably doing something wrong, but I just can’t see it right now. The simple cases with primitives from the docs works, but when I try to validate a more “normal” schema, I can’t get it to work. This is an example:

(def coord-schema
  [:map
   [:x :int]
   [:y :int]])


(defn down
  {:malli/schema [:=> [:cat coord-schema] [coord-schema]]}
  [coord]
  (update coord :y dec))
When I then do (dev/start!) I get the error
Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:119).
:malli.core/invalid-schema {:schema [:map [:x :int] [:y :int]]}
What am I missing?

niclasnilsson21:08:29

Looks like I was missing [:schema …]. This works.

(defn down
  "Some docstring"
  {:malli/schema [:=> [:cat [:schema coord-schema]] [:schema coord-schema]]}
  [coord]
  (update coord :y dec))

Akiz06:08:26

Do you have to use schema when you do not use instrumentation?

ikitommi06:08:34

@U48DE3SHM it should be:

(defn down
  {:malli/schema [:=> [:cat coord-schema] coord-schema]}
  [coord]
  (update coord :y dec))
e.g. don’t wrap schema in empty vector, invalid malli syntax.

niclasnilsson10:08:54

Ah, so my initial problem was the vector on the output all along. I see. Thanks, @U055NJ5CC.

niclasnilsson10:08:51

@zikajk, I don’t know, but my goal was to use the devevelopment instrumentation, using (dev/start!)

ikitommi10:08:11

the error message was really bad btw: `

malli.core/invalid-schema {:schema [:map [:x :int] [:y :int]]}
could have been something like:
malli.core/invalid-schema {:type [:map [:x :int] [:y :int]]
                           :schema [[:map [:x :int] [:y :int]]]}

👍 3
Akiz11:08:12

@U48DE3SHM I experienced two different errors during schema validation when using instrumentation. Restarting helped though…

niclasnilsson05:08:32

@zikajk, ah, thanks, I’ll keep that in mind going forward.

👍 3