malli

https://github.com/metosin/malli :malli:
ikitommi 2020-12-21T14:33:32.223Z

@raymcdermott listened that defn, good stuff. Finnish is simple, just pronounce the way you write it, right? ๐Ÿ˜‰

1
๐Ÿ˜„ 1
ikitommi 2020-12-21T14:35:28.224500Z

but, reitit is pronounced ray-tit.

๐Ÿ˜‚ 1
ikitommi 2020-12-21T14:36:20.225200Z

@rutledgepaulv the entry handling is bit too hard atm, but not sure what woud be a simpler way.

ikitommi 2020-12-21T14:36:42.225800Z

there is a way to ask for the entry instead of the value, just a sec.

ikitommi 2020-12-21T15:31:52.226500Z

oh, undocumeted, untested and had a bug, but maybe something like this?

(mu/find
  [:map [:b {:optional true} int?]]
  :b)
; => [:b {:optional true} int?]

(-> [:map [:a [:map [:b {:optional true} int?]]]]
    (mu/get :a)
    (mu/find :b))
; => [:b {:optional true} int?]

๐Ÿ‘ 1
ikitommi 2020-12-21T15:33:11.227300Z

where mu/find is just sugar on top of the hidden feature of โ€œgive me the entry tupleโ€ of:

(-> [:map [:a [:map [:b {:optional true} int?]]]]
    (mu/get-in [:a [::m/find :b]]))
; => [:b {:optional true} int?]

ikitommi 2020-12-21T16:12:15.227500Z

https://github.com/metosin/malli/pull/322

ikitommi 2020-12-21T16:13:53.228500Z

btw, those interested in the sequence schemas, hereโ€™s the PR (draft): https://github.com/metosin/malli/pull/317

ikitommi 2020-12-21T16:17:49.229400Z

(m/explain
  [:+ [:cat*
       [:prop string?]
       [:val [:alt* [:s string?] [:b boolean?]]]]]
  ["-server" :foo "-verbose" true "-user" "joe"])
=>
{:schema [:+ [:cat* [:prop string?] [:val [:alt* [:s string?] [:b boolean?]]]]],
 :value ["-server" :foo "-verbose" true "-user" "joe"],
 :errors (#Error{:path [0 :val :s], :in [1], :schema string?, :value :foo}
          #Error{:path [0 :val :b], :in [1], :schema boolean?, :value :foo})}

๐Ÿ”ฅ 1
dominicm 2020-12-21T17:26:41.229600Z

Can confirm, Ray is a tit ;) @raymcdermott