malli

2025-01-13T20:13:01.832119Z

Proposing some new schemas to increase expressivity of map keysets https://github.com/metosin/malli/pull/1161

;; if :git/tag is provided, then so should :git/sha
(def TagImpliesSha
  [:and
   [:map
    [:git/sha {:optional true} :string]
    [:git/tag {:optional true} :string]]
   [:implies [:has :git/tag] [:has :git/sha]]])

(m/validate TagImpliesSha {:git/sha "abc123"}) ;=> true
(m/validate TagImpliesSha {:git/tag "v1.0.0" :git/sha "abc123"}) ; => true

(me/humanize
  (m/explain TagImpliesSha {:git/tag "v1.0.0"}))
; => {:git/sha ["missing required key"]}

👍 2
👀 1
🎉 2
namenu 2025-01-14T10:09:26.992889Z

This is amazing. The virtue of being "open to changes" often results in this kind of implicit rules. I think I'm going to use this a lot once this PR is merged.

❤️ 1
➕ 1
2025-01-14T19:13:04.410859Z

btw I'll probably talk about this during this podcast (live soon) https://www.youtube.com/watch?v=VG8nu55bpts

2025-01-14T20:24:17.446359Z

didn't talk too much about it in the end, was nerd sniped into explaining transducers

🤣 1
ikitommi 2025-02-16T09:05:59.384799Z

hey, finally time to look for this (and others).

2025-02-16T18:36:27.664809Z

@ikitommi thanks! I'll let you know when the next iteration is ready.

👍 1