Fork me on GitHub
#malli
<
2021-11-10
>
rafd16:11:29

I'm trying to get the properties of a map entry, and struggling. For example, given the following schema, I'd like to access the properties of :widget/id (ie. get back {:foo/bar 123}):

(def Widget
  [:map
   [:widget/id {:foo/bar 123} uuid?]])
I thought this would work, but it returns an invalid-schema error:
(m/properties (m.util/find Widget :widget/id))
Any suggestions?

ikitommi18:11:22

@U0CLNM0N6 it returns the vector of [key ?props children] as a vector:

(def Widget
  [:map
   [:widget/id {:foo/bar 123} uuid?]])

(mu/find Widget :widget/id)
; => [:widget/id #:foo{:bar 123} uuid?]

(m/children Widget)
; => [[:widget/id #:foo{:bar 123} uuid?]]

ikitommi18:11:39

you can call second on it to get the props.

rafd18:11:20

Thanks Tommi. I did end up using second, but asked to check if there was a "malli-specific" approach.

ikitommi18:11:26

👍 there are no helpers for handling entries atm. but they are tuple3 always, quite easy to work with 😉