Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(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)))
[& args]
(if cljs.spec/*instrument-enabled*
(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