Your code works for me as expected on 1.9.0 Alpha 10. What version are you 
using?

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 7/20/16, 2:59 PM, "Torsten Anders" <clojure@googlegroups.com on behalf of 
torstenand...@gmx.de> wrote:

 

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 clojure@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+unsubscr...@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 the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to