Fork me on GitHub
#clojure-spec
<
2018-01-01
>
ikitommi15:01:58

Thanks @dominicm for the pointer. Looks great, seems to lean on custom strict-keys Spec to catch the typos. Coudn’t get it working as it uses really old version of spec, but will poke around to see if I could get it working. Different artifact name btw in Clojars and in Github.

drcode19:01:50

Hi everyone- I have a clojure DSL that comes in two variants that are about 95% the same and I want to write a single spec that validates both variants- What is the best way of doing this? Basically what I want to do is write about a hundred clojure.spec/def declarations that are the same for both variants, but a few deeply nested items will need idiosyncratic logic, looking something like:

(s/def :deeply/nested-item
     (if variant1? 
          variant-1-specification
          variant-2-specification))
I know I can solve this through some nasty macrology (that maintains two separate namespaces of specs for the two variants, so that the idiosyncratic differences can be "spliced in") but usually it is a bad idea to lean heavily on complex macros... Thanks for any tips!

gfredericks19:01:20

aaron brooks was just talking to me on twitter about this sort of thing

drcode20:01:16

@gfredericks yep, that's my situation...

drcode20:01:53

yes, I think I'll just use @abrooks' cheat until "spec specs" are available- Thanks for the pointer!