Fork me on GitHub
#clojure-spec
<
2021-01-05
>
benny23:01:16

is it possible to write specs for maps like you can in schema?

(def User
  {::id   s/Int
   ::name s/Str})
vs
(s/def ::id int?)
(s/def ::name string?)
(s/def ::user
  (s/keys :req [::id ::name]))

Alex Miller (Clojure team)23:01:23

that is how you do it in spec

benny23:01:29

there’s no way to do it inline like schema?

Alex Miller (Clojure team)23:01:24

no, there is a philosophical difference in approach here

Alex Miller (Clojure team)23:01:16

spec is trying to build a registry of spec'ed attributes. the attributes are seen as primary, the map only as container.

clj 9
Alex Miller (Clojure team)23:01:56

spec 2 is developing this further and will have some support for unqualified attributes with inline specs in a schema

🆒 3