--
You received this message because you are subscribed to the Google Groups "Plumbing and Graph: the Clojure utility belt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prismatic-plumbing+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi! I think we played with doing something like that but we couldn't figure out a good general solution that seemed always better, so we prefer just providing an explicit hint in this case.One easy workaround is to use `s/named` to provide a semantic name. This can also be accomplished with defschema.(def int-or-str (s/named (schema/cond-pre schema/Int schema/Str) 'int-or-string?))or(s/defschema int-or-str (schema/cond-pre schema/Int schema/Str))
The other way is to use `s/conditional`. You have to provide the conditions but this way you can provide the replacement for `matches-some-precondition?` directly (rather than wrapping the above error with a name).(def int-or-str (s/conditional int? s/Int string? s/Str 'int-or-string?))Do either of those work for you?Thanks,Jason
On Fri, Apr 28, 2017 at 6:48 AM, Rovanion Luckey <rovanio...@gmail.com> wrote:
I should perhaps begin by saying that I'm a complete newcomer to
Schema and that the issue may simply be that I'm using it wrong.
But it seems to me like `check` could do a better work when it comes
to explaining cond-pre-schemas:
```clojure
(def int-or-str
(schema/cond-pre schema/Int schema/Str))
(schema/check int-or-str :a)
; => (not (matches-some-precondition? :a))
```
Instead of simply saying "it matches nothing", perhaps the error
message could say "it doesn't match either X, Y or Z" with X, Y and Z
being the individual preconditions.
Is there some way to get a better error message out of Schema or
can this be considered a feature request?
--
You received this message because you are subscribed to the Google Groups "Plumbing and Graph: the Clojure utility belt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prismatic-plumbing+unsubscribe@googlegroups.com.
Do either of those work for you?