Hi All, I have different type of model in my domain like User, Credit. I would like to define spec of the model in one clj/cljs but not different clj/cljs file. Because I don't want to create one clj file for per model. On the other hand Clojure namespaces are very similar to Java packages. (https://github.com/clojuredocs/guides/blob/master/articles/language/namespaces.md)
Additionally I could not defined same keyword with different predicate in one namespace. So what I did in bellow. (ns model (:require [clojure.spec :as s] [clojure.walk :as w])) (defn update-ns " " [ns-str spec-list] (w/postwalk (fn [v] (if (and (keyword? v) (= (namespace v) (str *ns*))) (keyword (str ns-str "/" (name v))) v) ) spec-list)) (defmacro in-spec "" [n & content] (let [content (update-ns n content)] `(do (clojure.core/in-ns '~(symbol n)) (clojure.core/refer 'clojure.core) (clojure.core/require '[clojure.spec :as ~(symbol 's)]) ~@content nil))) (in-spec User (s/def ::id string?)) (in-spec Credit (s/def ::id number?)) (s/valid? :User/id "Musterman") (s/valid? :Credit/id 12345) (s/valid? :Credit/id "Error") Although I am creating namespace here but it is not visible here. I would like to know Is there any better way to do or any core function that I could use here? Thanks, Mamun -- 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.