Fork me on GitHub
#malli
<
2023-01-30
>
jasonjckn18:01:29

has anyone written a generic malli schema to spec converter function i can steal? as i transition a code base over to malli, would be a helpful tool

☝️ 2
pithyless18:01:43

I remember this thread: https://clojurians.slack.com/archives/CLDK6MFMK/p1663090650431439 No idea if anything changed from that time.

jasonjckn18:01:53

Thanks 🙏 this looks interesting from the thread and exactly my use case https://github.com/Blasterai/malli-datomic

emilaasa18:01:24

I've got this dream as well 🙂

escherize23:01:41

I’m trying to do generative testing on some functions created with mx/defn. Is there a good way to see how many things match a filter for mi/check?

(mi/check {:filters [(mi/-filter-var #{#'my/wacky-fxn})]})
I’d like to double check that I actually got a var. Ideally check would return something like {my.ns/wacky-fxn :ok}. Does this exist somewhere already? It looks like -strument calls into :mode after the var lookup doesn’t happen. I can build a similar thing myself in that case

escherize23:01:59

I figured it out, I can pass my own mode function into -strument!

escherize04:01:43

I ended up just passing the var into this

(defn- check-fn! [fn-var & [iterations]]
  (let [iterations (or iterations 5000)]
    (if-let [result ((mg/function-checker (:schema (meta fn-var)) {::mg/=>iterations iterations}) @fn-var)]
      result
      {:pass? true :iterations iterations})))
which will throw if the var isn’t resolvable