Fork me on GitHub
#malli
<
2021-07-29
>
danielneal09:07:02

is there an malli.util/assoc that will allow to set the properties and schema of a key

danielneal09:07:08

or a different function?

greg10:07:41

That was part my question I posted https://clojurians.slack.com/archives/CLDK6MFMK/p1627435833075200. I did not found a way of doing it at Malli. But it is fairly easy to do using m/children. If you have a look at my other https://clojurians.slack.com/archives/CLDK6MFMK/p1627471982078700?thread_ts=1627435833.075200&amp;cid=CLDK6MFMK on this channel, I wrote a few utility methods. One of them is update-child-props. It was a first draft, I modified them since then, but even with it, you can do what you want, e.g.

(update-child-props (m/schema [:map [:y {:default 20} int?]]) :y update :default dec) 
;; => [:map [:y {:default 19} int?]]

(update-child-props (m/schema [:map [:y {:default 20} int?]]) :y assoc :limit 50)           
;; => [:map [:y {:default 20, :limit 50} int?]]

greg12:07:10

Unless I misunderstood "allow to set the properties and schema of a key" 😅

ikitommi13:07:54

maybe:

(mu/assoc 
  [:map [:y {:old true} int?]] 
  [:y {:new true}] string?)
; => [:map [:y {:new true} string?]]

danielneal14:07:35

aha, thanks!

Itay13:07:58

Hi, I posted this in the #reitit channel but still did not get any response. No reply on the issue I opened either. Since it is Malli related, I thought perhaps I could get some feedback here. Thanks.

ikitommi13:07:38

@itaysabato I can take a look at that today/tomorrow

Itay08:08:56

Good morning 🙂 Any news regarding this issue?

ikitommi13:08:15

totally forgot, sorry. will try to look later today.

👍 2
ikitommi06:08:05

did a PR, might fix it. Depending on the exceptations

Itay08:08:07

Thank you for this! Looks like it did. I commented on one line that I didn't get, but the rest looks solid to me.

ikitommi09:08:07

answered. I'm not near computer, if you could verify the old behavior (does it strip extras or not), would help. Thanks.

Itay10:08:03

Sorry, I was away for a few days. Is it still relevant to test the old strip keys behavior? I will soon try the fixed version

Itay13:07:04

@ikitommi That would be lovely, thank you!

ikitommi13:07:19

quick poke on instrumentation: malli.dev/start! will now collect function schemas from all public vars from all loaded namespaces.

ikitommi13:07:09

I would like to add Var-watches too, so any Var change would re-trigger instrumentation of that Var. But didn’t work in the 30min timebox I had for it.

ikitommi13:07:11

anyway, dx should be better than before. feedback welcome on the instrumention. If anyone has tried that…

ikitommi14:07:46

goal is to do the first version of pretty error reporting for 0.6.0, to celebrate the two year birthday of the initial demo of that (https://github.com/metosin/malli/issues/19). Making open source 1h here and there isn’t the fastest way to finish stuff 😎

🎉 9
Noah Bogart14:07:51

hey all, just started using malli in a new part of my project, and i’m struggling to check if a value is a function

Noah Bogart14:07:06

(def Step
  [:map {:closed true}
   [:uuid uuid?]
   [:continue-fn fn?]
   [:complete? boolean?]
   [:phase keyword?]])

ikitommi14:07:16

should work

ikitommi14:07:51

fn? was added few days ago thou, it was missing. you should depend on the latest sha

Noah Bogart14:07:02

ah that’s probably it, i’m using the clojars version

ikitommi14:07:23

[:fn fn?] works also. :fn is the escape hatch, “any function”

👍 3
Noah Bogart14:07:23

that works! thanks so much

👍 3
ikitommi14:07:39

immutable clojars-snapshot of the latest stuff:

➜  ~ clj -Sforce -Sdeps '{:deps {metosin/malli {:mvn/version "0.6.0-SNAPSHOT"}}}'
Downloading: metosin/malli/0.6.0-SNAPSHOT/malli-0.6.0-20210729.141459-4.pom from clojars

Noah Bogart14:07:18

missed that there were further docs, i’ll read over that now