             [cfpb.qu.query.select :as select]
             [cfpb.qu.query.parser :as parser]))
 
-(declare match project group sort validate)
-
-(defn- valid? [query]
-  (= 0 (reduce + (map count (:errors query)))))
+(declare valid? match project group sort validate post-process-validate)
 
 (defn process
   "Process the original query through the various filters used to

  (let [query (validate query)]
    (if (valid? query)
      (-> query
          match
          project
          group
          sort)
      query)))

(defn- add-error
  [query field message]
  (update-in query [:errors field]
             (fnil #(conj % message) (vector))))

(defn match
  "Add the :match provision of the Mongo query. Assemble the match

       flatten
       (filter keyword?)))

(defn- add-error
  [query field message]
  (update-in query [:errors field]
             (fnil #(conj % message) (vector))))

(defn- validate-field
  [query clause column-set field]
  (let [field (name field)]
