We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 30ab498 commit 8399062Copy full SHA for 8399062
1 file changed
src/main/cljs/cljs/spec.cljs
@@ -177,8 +177,8 @@
177
[spec x]
178
(explain-data* spec [] (if-let [name (spec-name spec)] [name] []) [] x))
179
180
-(defn explain-out
181
- "prints an explanation to *out*."
+(defn explain-printer
+ "Default printer for explain-data. nil indicates a successful validation."
182
[ed]
183
(if ed
184
(print
@@ -209,6 +209,14 @@
209
(newline)))))
210
(println "Success!")))
211
212
+(def ^:dynamic *explain-out* explain-printer)
213
+
214
+(defn explain-out
215
+ "Prints explanation data (per 'explain-data') to *out* using the printer in *explain-out*,
216
+ by default explain-printer."
217
+ [ed]
218
+ (*explain-out* ed))
219
220
(defn explain
221
"Given a spec and a value that fails to conform, prints an explanation to *out*."
222
0 commit comments