Skip to content

Commit 0e8ae7a

Browse files
committed
backport src/compojure/api/coercion/core.clj
1 parent 540b169 commit 0e8ae7a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(ns compojure.api.coercion.core)
2+
3+
(defprotocol Coercion
4+
(get-name [this])
5+
(get-apidocs [this model data])
6+
(make-open [this model])
7+
(encode-error [this error])
8+
(coerce-request [this model value type format request])
9+
(accept-response? [this model])
10+
(coerce-response [this model value type format request]))
11+
12+
(defrecord CoercionError [])
13+
14+
(defmulti named-coercion identity :default ::default)
15+
16+
(defmethod named-coercion ::default [x]
17+
(let [message (if (= :spec x)
18+
(str "spec-coercion is not enabled. "
19+
"you most likely are missing the "
20+
"required deps: org.clojure/clojure 1.9+ "
21+
"and metosin/spec-tools.")
22+
(str "cant find named-coercion for " x))]
23+
(throw (ex-info message {:name x}))))

0 commit comments

Comments
 (0)