Fork me on GitHub
#clojure-spec
<
2022-07-17
>
apbleonard19:07:29

If I had a map with :billing-address and :shipping-address keys whose associated values were expected to be valid against the same ::address spec, could I express that in spec/keys directly - i.e. without creating intermediary ::billing-address and ::shipping-address specs? Also not sure if (spec/def ::billing-address ::address) or something like it, is an option?

Alex Miller (Clojure team)20:07:24

you would need to do the latter, which is an option

Alex Miller (Clojure team)20:07:31

it's often convenient to have both structural specs (like address) and named attributes that refer to those

apbleonard22:07:19

Ok fab - thanks @alexmiller Probably seen that in code many times but not really thought about it much. Trying to build a API data dictionary at work that promotes specifying attributes over HTTP request/responses bodies (to avoid the repetition that brings.) Looks like I will need to list these named specs in the dictionary as well as the attributes themselves.