                                   has-y false]
                              (let [first-field (first curr-fields)
                                    rest-fields (rest curr-fields)]
-                               (if (not (empty curr-fields))
+                               (if (seq curr-fields)
                                  (cond
                                    (= (::sp/channel first-field) ::sp/x)
                                    (recur rest-fields

                                   (= (::sp/channel first-field) ::sp/y)
                                   (recur rest-fields
                                          has-enumerated-non-position-or-facet-channel has-x true)
                                   (not= (::sp/channel first-field) ::sp/?)
                                   (if (sp/is-channel-enumerated? spec)
                                     (recur rest-fields
                                            true has-x has-y)
                                     (recur rest-fields
                                            has-enumerated-non-position-or-facet-channel has-x has-y)))
                                 (if has-enumerated-non-position-or-facet-channel
                                   (and has-x has-y)
                                   true)))

                               (if (not (empty curr-fields))
                                 (if (not= (::sp/channel first-field) ::sp/?)
                                   (if (not (sp/is-spatial-channel? (::sp/channel first-field)))
                                     (if (and
                                           (> non-positional-channel-count 1)
                                           (has-enumerated-non-positional-channel))
                                       (recur rest-fields (+ non-positional-channel-count 1) true (and result false))
                                       (recur rest-fields (+ non-positional-channel-count 1) true (and result true)))
                                     (recur rest-fields non-positional-channel-count false (and result true)))
                                   (recur rest-fields non-positional-channel-count false (and result true)))
                                 result
                                 )))))
                       ])


(defn field-constraints-satisfied?
  [fields constraints]
  (loop [curr-fields fields res true]
    (if (not (seq curr-fields))
      res
      (recur (rest curr-fields)
        (reduce (fn [x y] (and x (satisfied? y (first curr-fields)))) res constraints)))))


(defn spec-constraints-satisfied?
  [spec constraints]
  (reduce (fn [x y] (and x (satisfied? y spec))) true constraints))


(defn filter-invalid-specs
  [specs]
  (->> specs
       (filter (fn [x] (field-constraints-satisfied? (::sp/fields x) field-constraints)))
       (filter (fn [x] (spec-constraints-satisfied? x spec-constraints)))))
