This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-07
Channels
- # architecture (35)
- # babashka (9)
- # beginners (31)
- # biff (15)
- # calva (8)
- # catalyst (3)
- # cider (7)
- # clerk (4)
- # clj-kondo (24)
- # clj-yaml (10)
- # clojure (58)
- # clojure-europe (65)
- # clojure-japan (1)
- # clojure-nl (1)
- # clojure-norway (89)
- # clojure-spec (1)
- # clojure-sweden (1)
- # clojure-uk (8)
- # clojurescript (14)
- # cursive (3)
- # datahike (1)
- # datomic (29)
- # emacs (8)
- # graalvm (20)
- # graphql (1)
- # gratitude (2)
- # helix (6)
- # hyperfiddle (65)
- # jobs-discuss (7)
- # leiningen (1)
- # lsp (6)
- # malli (14)
- # missionary (12)
- # nrepl (8)
- # off-topic (24)
- # polylith (29)
- # reagent (14)
- # sci (14)
- # shadow-cljs (6)
- # spacemacs (10)
- # sql (4)
what is the correct spec to use for a seq that could be a vector or a list or a set? the docs say "You can use :sequential for any homogeneous Clojure sequence", but that's not true:
(for [v [[1]
(list 1)
#{1}]]
[v (m/validate [:sequential any?] v)])
;; ([[1] true]
;; [(1) true]
;; [#{1} false])
use case: a public API that can accept both EDN and JSON data. EDN uses sets, JSON uses arrays, which marshall to vectorsa set isn't sequential?
in clojure although it is seqable (order is not guaranteed). you could make an :or
schema with :sequential
:set
to capture both value forms.
but I'd also consider canonicalizing the API input value into a set before processing further.
also, there is mt/collection-transformer
to change any (supported) collection type to another
thanks folks
@U055NJ5CC :sequential does allow lists 🙂
Hello! Is this behavior expected?
dev> (m/encode [:and [:keyword] [:enum :one :two]] :one mt/string-transformer)
"one"
dev> (m/encode [:enum :one :two] :one mt/string-transformer)
:one
Ok, I will!