There is no way in keys to say "use this spec" like:
(s/def ::foo (s/keys :req [(::bar string?)]) )
something like this right? What is the most concise alternative?you mean to specify an ad hoc spec for a key? no
(s/def ::bar string?)
(s/def ::foo (s/keys :req [::bar]))spec 2 has some facility for specifying ad hoc specs for unqualified keys in a schema
(s/def ::foo
(fn [m]
(and
(s/valid? ::foo-default-keys (dissoc m ::special))
(s/valid? ::foo-special-key (select-keys m [::special])))))
if I do this my design is wrong I feel likewhy is special so special?
I find things that are hard to spec often point to problems in the code/data design
Wouldn't this statement be true in general? What I mean is, when something is problematic it's not enough to know it's problem in "code/ data design" because it's not clear how to unproblem it 🙂