Fork me on GitHub
#expound
<
2019-07-04
>
Aleksander10:07:48

Hi all, is there a good way to a) use custom opts (disabling printing specs) b) use expound to format some but not all spec errors (only the ones intended to be read by operators of the system) Browsing through the code it seems that you can only set custom-opts via set! or alter-var-root with custom-printer which would effect all spec errors

bbrinck14:07:09

@dev964 Are you looking to use spec to print out instrumentation errors or errors on some data that you have in your program?

bbrinck14:07:51

e.g. checking some data that incoming from another part of the system

Aleksander14:07:59

the second one

Aleksander14:07:10

and I ended up not using expound in the end …

bbrinck14:07:15

Would binding work in your case?

(binding [s/*explain-out* (expound/custom-printer {:show-valid-values? true})]
    (s/explain (s/coll-of string?) ["" "" 3]))

bbrinck14:07:40

That would apply the custom settings only for the block of the binding

Aleksander14:07:44

yes, would work - but it was easier to construct the messages myself this time

bbrinck15:07:12

Ah, OK, sounds good!

bbrinck15:07:19

In a future version, you’ll be able to do (expound/expound (s/coll-of string?) ["" "" 3] {:show-valid-values? true}) to add the options inline, but I haven’t released that yet

👍 4
bbrinck15:07:25

In any case, glad you found a solution!