Fork me on GitHub

yea, i had a few of those too but since these are registered "globally" they're fair game to my (spec-based) fuzzer. so, i'm making the ones in my project "defensive" against this (although it should never happen from production code)


i.e., this is where the inputs are coming from (with the one exceptional case i've found [which crashes] excluded):

(s/cat :spec (s/with-gen qualified-keyword? #(gen/elements
                                                  (set (keys (s/registry)))
        :val any?)


Hello! I made a function to return specs depending on arguments.

(defn- search-schema-spec-for-of-and-defaultValue [of defaultValue]
  (s/keys :req-un [
          :opt-un [
It’s called like the following,
But I get the following error
Unexpected error (AssertionError) macroexpanding s/keys at (src/sharetribe/build_api/routes.clj:136:3).
Assert failed: all keys must be namespace-qualified keywords
(every? (fn* [p1__1917#] (c/and (keyword? p1__1917#) (namespace p1__1917#))) (concat req-keys req-un-specs opt opt-un))
I just wanna factor out common parts and make different specs based on of and defaultValue as they are the differentiator, any advice on how to achieve?


use macros or eval instead of defn — s/keys is a macro


Thanks! @U47G49KHQ I defined common spec separately and combined with s/and and this seems to work good enough for me!

(def build-api-search-schema-common-spec
  (s/keys :req-un [
          :opt-un [

(s/and build-api-search-schema-common-spec (s/keys :req-un []
                                                     :opt-un []))



If you’re combining map specs you might want to look at s/merge as well

👍 1