Is it possible to override a default spec generator so that data is always generated only for a single branch of the s/or
composite spec?
(s/def ::x
(s/or :x-a nat-int?
:x-b string?))
(gen/sample (s/gen ::x))
;; generate strings only
Is it possible to override a default spec generator so that data is always generated only for a single branch of the s/or
composite spec?
(s/def ::x
(s/or :x-a nat-int?
:x-b string?))
(gen/sample (s/gen ::x))
;; generate strings only
Copyright © 2021 Jogjafile Inc.
You can use
s/with-gen
to supply a custom generator:You could also use it only where you're sampling, without modifying the base
::x
spec:There are other spec functions that accept a map of overrides for the same purpose, e.g.
s/exercise
: