So something like
(defn valid-or-explain [spec data]
(let [v (s/valid? spec data)]
(when-not v (s/explain spec data))
v))
I'll mention it to Rich, not sure though.
On Tuesday, May 24, 2016 at 10:56:03 PM UTC-5, puzzler wrote:
>
> One thing that has always limited the value of pre and post conditions is
> that they don't give useful error messages.
>
> I would like to see function in the spec namespace that returns true if
> input conforms to a spec, otherwise returns false and prints to standard
> out an explanation of the failure. Sort of a valid-or-explain predicate
> (but a shorter name would be better).
>
> In some sense, fdef is superior to using pre and post assertions, so maybe
> at some point they will feel obsolete, but possibly not -- things defined
> with fdef have to be explicitly instrumented, but pre and post assertions
> automatically follow the behavior set for all assertions.
>
> So as long as pre and post assertions have value, I think many people are
> going to cobble together their own implementation of valid-or-explain.
> Better to have one standard implementation that everyone can rely on.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.