Dear all,
I have some problems using clojure.spec: ? does not work as I would expect
it. Instead of specifying an optional value, it seems that such values are
never permitted, and instead the next value is always matched. Please see
the short example demonstration below. BTW, * seems to cause the same
problem.
What am I missing?
(ns test-ns
(:require [clojure.spec :as spec]))
(spec/def ::test-spec (spec/cat :symbol symbol?
:optional-string (spec/? string?)
:int int?))
(spec/valid? ::test-spec '[test 42]) ; -> true
(spec/valid? ::test-spec '[test "my string" 42]) ; -> false
(spec/explain ::test-spec '[test "my string" 42])
;; In: [1] val: "my string" fails spec: :clojure2minizinc.core/test-spec
at: [:int] predicate: int?
Best,
Torsten
--
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.