clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
tianshu 2020-07-06T06:01:18.443100Z

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 .

alexmiller 2020-07-06T12:36:39.443800Z

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

alexmiller 2020-07-06T12:38:04.444700Z

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

tianshu 2020-07-06T14:34:46.445800Z

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

Joe Lane 2020-07-06T15:08:28.445900Z

Hey @jayzawrotny, I'm a little late to the party, but I found this blog post to be very apropos https://juxt.pro/blog/cljs-apps

2020-07-06T15:10:04.446400Z

Thanks @lanejo01