Hi there,
right now i am using spec to match some input data with something like this
(require '[clojure.spec.alpha :as spec])
(spec/conform (spec/cat :stuff (spec/alt
:strings (spec/* string?)
;:default (spec/* identity)
)
:rest (spec/* identity))
["some string" 2 2])
=> {:stuff [:strings ["some string"]], :rest [2 2]}
But if i add a "default" to alt it returns something unexpected
(spec/conform (spec/cat :stuff (spec/alt
:strings (spec/* string?)
:default (spec/* identity))
:rest (spec/* identity))
["some string" 2 2])
=> {:stuff [:default ["some string" 2 2]]}
The
docs
https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html#clojure.spec.alpha/alt
says:
Returns a regex op that returns a map entry containing the key of the
first matching pred and the corresponding value.
I would expect that (spec/* string?) is the first matching pred and not the
(spec/* identitiy).
Is this behavior correct?
Thanks J
--
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.