Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by

Assume i have the following spec:

(ns example
(:require [clojure.alpha.spec :as s]))

(s/def ::val int?)
(s/def ::inner (s/schema [::val]))

(s/def ::container (s/coll-of ::inner
                              :into []))

(s/def ::outer (s/schema [::container]))

How does a s/select look like so that ::container is always in ::outer and it may be empty, but if it has an element ::val has to be there.

Eg, this should not be valid

[#:example{:container [{}]}]

1 Answer

+1 vote
by

There is no syntax for this kind of interleaving of colls and maps right now but we recognize that's a common thing and have talked about it without settling on how that might look yet. So TBD.

...