Hi folks - was wondering if there is a way to extract the type from a vector inside :maybe
Currently this does:
(m/type [:maybe [:enum "foo"]]) ;;=> :maybe
Is there a way to get :enum instead?
user=> (-> [:maybe [:enum "foo"]] (mu/get 0) m/type)
:enum
yeah that means though I have to go nested only if :maybe is there
I guess I though I could somehow distinguish between an type schema and a "meta" schema (I guess there is a better name for those)
yes you'll need to write an algorithm that discards each schema you consider superfluous
yep
thank you for validating that 😄
found malli.util/find-first and I am using that
seems sufficient for unwrapping :maybe . you might want to m/deref-all at each step to resolve refs.
didn't think about that thanks
gets a bit awkward with find-first because you can't tell it to continue with the deref'd schema. maybe something simpler like a recursive fn with a case is better.
(fn rec [s]
(let [s (m/deref-all s)]
(case (m/type s)
:maybe (rec (mu/get s 0))
s)))
oh nice thank you!
this definitely gets me going
good luck!