Hi all,
I'm writing a spec for a cursor-like type - a map with some ::data, a ::path
into the data, and a ::value - the value in the data at that path
I've written a spec that captures the constraint that (= (get-in data path)
value)
(s/valid? (s/and (s/keys :req [::val ::data ::path])
(s/or :a (s/and #(empty? (::data %))
#(empty? (::path %)))
:b #(= (::val %) (get-in (::data %) (::path %)))))
{::data [:zob] ::path [0] ::val :zob})
=> true
However, if I swap the operands to s/and around:
(s/valid? (s/and (s/or :a (s/and #(empty? (::data %))
#(empty? (::path %)))
:b #(= (::val %) (get-in (::data %) (::path %))))
(s/keys :req [::val ::data ::path]))
{::data [:zob] ::path [0] ::val :zob})
=> false
I have a bigger example where the workaround of swapping the operands doesn't
help. Looking at the spec failure message, I notice the :val is not the value I
passed, but a vector [:kw x] where x is the actual value, and :kw is one of the
keyword tags from an (s/or) used in a sub-spec, which obviously shouldn't be in
there.
Is this a known issue?
If not I'll work on a minimal repro.
Thanks
Tom
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.