Fork me on GitHub
#clojure-spec
<
2020-07-06
>
tianshu06:07:18

I want to use s/multi-spec to validate a map that has a few different structures. And I'm using s/conform to test if the map is satisfy the spec, but I can't find a way to figure out what branch it is matched since the conform on a multi-spec just simply return a map without more information. how can I know which branch it matched, like in s/or .

Alex Miller (Clojure team)12:07:39

I assume you're not just checking a keyword in the map, it's something more complicated

Alex Miller (Clojure team)12:07:04

I don't think you're going to automatically get this, but you could add a conformer to the different cases to "tag" the map with a branch identifier

tianshu14:07:46

@alexmiller I end up call that dispatch function again to get the branch identifier.