Prismatic Schema - Why is "both" deprecated?

207 views
Skip to first unread message

JvJ

unread,
Mar 5, 2016, 7:08:35 PM3/5/16
to Clojure

I've noticed that there is the function "both" in Schema.

Both says that it can be replaced by conditional, but I'm not sure exactly how to go about doing this.

Can someone provide an example?

Thanks

Jason Wolfe

unread,
Mar 6, 2016, 9:48:21 PM3/6/16
to Clojure
In place of (s/both long (s/pred odd?)) you can do (s/conditional odd? long), but (s/constrained long odd?) probably provides better error messages (since it validates long before odd?). I think there are some examples in the readme. 

If this isn't what you're looking for, can you please provide some more details of your use case? 

Thanks,
Jason

JvJ

unread,
Mar 7, 2016, 1:11:19 AM3/7/16
to Clojure
In this example, one of the schemas is a predicate schema.  What if neither of them are?

Jason Wolfe

unread,
Mar 7, 2016, 5:28:57 AM3/7/16
to Clojure
Yes, that use case (two different non-predicate schemas) is no longer
supported. While superficially simple, it added a fair bit of
complexity and had corner cases that are not present with
`conditional` or `constrained`. Moreover, in our experience the
primary use case for `both` by far was with a predicate, and in the
other cases there is typically a reasonable alternative. Can you
elaborate on what your use case looks like?

Thanks, Jason
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/1Xfr_VS2yV4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages