Hi guys! Is there a way to conditional path in multi-path ?
(def foo #{:a :b :c})
(s/multi-transform
(s/multi-path
(when (foo :a) [...]))
{})@jean.boudet11 check out cond-path
cond-path check the current structure no? Because on the example above, I expected :foo #{}
(s/multi-transform
(s/multi-path
[:baz (s/terminal-val 1)]
[(s/cond-path
false [:foo s/NONE-ELEM (s/terminal-val 2)])])
{:foo #{}})
;; => {:baz 1 :foo #{2}}oh, if you literally just want the navigator itself to be determined by a non-structure related condition then you can use conditional in the path
the conditions in cond-path are "condition paths", which are considered true if they navigate to at least one value
the implicit navigator for a boolean is keypath, so the path false always navigates somewhere
in this case to the value nil
Thanks nathan for the explanation.
> you can use conditional in the path
I miss something because a path like (s/multi-path (when false [...])) will fail and I got the error All navigation in multi-transform must end in 'terminal' navigators
Maybe multi-transform doesn't allow this kind of stuff.
well, you still need a terminal navigator
but the path can be specified like that
(multi-path (if some-cond (term inc) STOP))
that would be one way to do it
Aah yes! Thank you!