Given the following spec definitions
(ns spec-playground.spec.standard
(:require [clojure.spec.alpha :as s]))
(defn- state-length [str]
(= 2 (count str)))
(s/def ::field-one string?)
(s/def ::field-two string?)
(s/def ::person (s/keys :req-un [::field-one ::field-two]))
(s/def ::city string?)
(s/def ::state (s/and string? #(state-length %)))
(s/def ::zip string?)
(s/def ::street string?)
(s/def ::address (s/keys :req-un [::street ::city ::state ::zip]))
(s/def ::addresses (s/coll-of ::address :distinct true :into [] :kind vector? :min-count 1 :max-count 5))
(s/def ::complete-person (s/keys :req-un [::person]
:opt-un [::addresses]))
(gen/sample (s/gen ::standard/addresses))
throws an error in the repl
Couldn’t satisfy such-that predicate after 100 tries {}
I did find this stack overflow post, but I’m not sure how to apply the given solution since I am not attempting to spec an entire function.
I would appreciate any insight into how to deal with this type of problem.