This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-26
Channels
- # announcements (2)
- # beginners (46)
- # calva (16)
- # cider (5)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (4)
- # clojure (42)
- # clojure-dev (2)
- # clojure-spec (6)
- # clojure-uk (1)
- # clojurescript (18)
- # cursive (7)
- # datomic (18)
- # duct (1)
- # fulcro (11)
- # graalvm (1)
- # hoplon (9)
- # leiningen (1)
- # off-topic (8)
- # shadow-cljs (16)
- # spacemacs (9)
- # specter (3)
- # sql (33)
- # vim (3)
- # xtdb (8)
Hi everyone! Can you please explain me why this spec doesn’t work correctly:
(s/def ::name string?)
(s/def ::src string?)
(s/def ::width pos-int?)
(s/def ::height pos-int?)
(s/def ::size
(s/schema {:src ::src
:width ::width
:height ::height}))
(s/def ::file
(s/select
(s/schema {:name ::name
:size ::size})
[:name :size {:size [*]}]))
(s/valid? ::file {:name "test"
:size {}})
;; => true
;; but should be false
but when I use fully-qualified keywords, s/valid?
works correctly
@y.khmelevskii I tried the following and it also produces true
user=> (s/def ::file (s/select (s/schema {:name ::name :size ::size}) [:name :size {:size [:src :width :height]}]))
:user/file
user=> (s/valid? ::file {:name "x" :size {}})
true
I'm not sure what restrictions are in place for unqualified key usage. It is all alpha, after all.Very much alpha at the moment @benzap
There hasn't even been an "alpha" release yet -- it's just on GitHub.