Fork me on GitHub
Marc O'Morain14:11:37

👋 Hi there. I’m looking for a way to author a specter path that can select a string or vector of strings. My data looks like this: (emails for the postal library).

(def m1 {:to ["" ""]
         :cc ""
         :bcc nil})

(def m2 {:to []
         :cc []
         :bcc [""]})
I want to collect all email addresses in the message, using specter/select

Marc O'Morain14:11:11

I ended up with:

(defn- has-recipients?
  "True if this email has any recipients"
  (s/selected-any? [(s/multi-path :to :cc :bcc)
                    (s/if-path sequential? s/ALL some?)]