Hello,

I started a new project with clojure.spec after a former project where I 
used Prismatic schema.

There is one thing I really don't get: how can I define two specs for maps 
with the same keys but not the same "types" in the same namespace?

Let's consider this example written with schema semantics:

(s/defn get-product-from-catalog-a [{:keys [type ref]} :- {:type (s/enum "a" 
"b" "c")
                                                           :ref s/Str}]
  ...)


(s/defn get-product-from-catalog-b [{:keys [type ref]} :- {:type (s/enum :x 
:y :z)
                                                           :ref s/Num}]
  ...)

I would naively start the spec this way with clojure.spec:

(s/def ::type #{"a" "b" "c"})
(s/def ::ref string?)

(defn get-product-from-catalog-a [{:keys [type ref]}]
  ...)

(s/fdef get-product-from-catalog-a
  :args (s/keys [::type ::ref])
  :ret any?)

;; ---


(s/def ::type #{:x :y :z})
(s/def ::ref number?)

(defn get-product-from-catalog-b [{:keys [type ref]}]
  ...)

(s/fdef get-product-from-catalog-b
  :args (s/keys [::type ::ref])
  :ret any?)

There is an obvious conflict for the ::type and ::ref specs.

Must I define those two functions in two different namespaces? Or is there 
a way to do it in the same namespace?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to