micro_blog_repo_fetchers/src/micro_blog/utils.clj

12 lines
427 B
Clojure

(ns micro-blog.utils
(:require
[taoensso.telemere :as tel]
[malli.core :as m]))
(defn validate-with-throw [value schema]
(tel/log! {:level :debug :data {:value value :schema schema}} "Validating value")
(if (m/validate schema value)
value
(do
(tel/log! {:level :error :data {:why (m/explain schema value)}} "Validation failed")
(throw (ex-info "Res does not follow schema" {:value value})))))