clojure-spec

apbleonard 2022-07-17T19:59:29.424189Z

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) 2022-07-17T20:42:24.152319Z

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

Alex Miller (Clojure team) 2022-07-17T20:43:31.689159Z

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

apbleonard 2022-07-17T22:20:19.847279Z

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.