This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn spec-checking-fn | |
"Patch for spec-checking-fn which doesn't serialize full data structure to string" | |
[v f] | |
(let [conform! (fn [v role spec data args] | |
(let [conformed (s/conform spec data)] | |
(if (= ::s/invalid conformed) | |
(let [ed (assoc (s/explain-data* spec [role] [] [] data) | |
::s/args args)] | |
(js/console.debug (str "Call to " (pr-str v) " did not conform to spec")) | |
(doseq [problem (::s/problems ed)] | |
(js/console.debug problem)) | |
(throw (ex-info (str "Call to " (pr-str v) " did not conform to spec") ed))) | |
conformed)))] | |
(cond-> | |
(fn | |
[& args] | |
(if cljs.spec/*instrument-enabled* | |
(s/with-instrument-disabled | |
(let [specs (s/get-spec v)] | |
(when (:args specs) (conform! v :args (:args specs) args args)) | |
(binding [cljs.spec/*instrument-enabled* true] | |
(apply f args)))) | |
(apply f args))) | |
(not (instance? MultiFn f)) (doto (gobj/extend f))))) | |
(set! cljs.spec/spec-checking-fn spec-checking-fn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment