diff --git a/src/malli/edn.cljc b/src/malli/edn.cljc index d2924e504..843239cc3 100644 --- a/src/malli/edn.cljc +++ b/src/malli/edn.cljc @@ -4,7 +4,7 @@ [malli.core :as m])) (defn -parse-string [x] - (edamame/parse-string x {:var resolve, :regex true, :fn true})) + (edamame/parse-string x {:regex true, :fn true, :var identity})) (defn write-string ([?schema] diff --git a/src/malli/registry.cljc b/src/malli/registry.cljc index e7bcb13f4..f6f1c48a7 100644 --- a/src/malli/registry.cljc +++ b/src/malli/registry.cljc @@ -63,10 +63,15 @@ (-schema [_ type] (-schema (registry @db) type)) (-schemas [_] (-schemas (registry @db))))) +(defn -find-loaded-var [s] + (->> (all-ns) (mapcat ns-publics) (some (fn [[_ v]] (if (= s (.toSymbol v)) v))))) + (defn var-registry [] (reify Registry - (-schema [_ type] (if (var? type) @type)) + (-schema [_ type] (cond + (var? type) @type + (and (list? type) (= 'var (first type)) (= 2 (count type))) (-find-loaded-var (second type)))) (-schemas [_]))) (def ^:dynamic *registry* {})