   [query]
   (validate-integer query :offset))
 
-(defn validate
-  "Check the query for any errors."
-  [query]
-  (if (or (:errors query)
-          (not (:slicedef query)))
-    query
-    (let [slicedef (:slicedef query)
-          dimensions (:dimensions slicedef)
-          metrics (:metrics slicedef)
-          column-set (set (concat dimensions metrics))]
-      (-> query
-          (assoc :errors {})
-          (validate-select column-set)
-          (validate-group column-set dimensions)
-          validate-where
-          validate-order-by
-          validate-limit
-          validate-offset))))
+(defn- post-process-validate
+  [query]
+  query)

       flatten
       (filter keyword?)))

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

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

(defn- valid? [query]
  (= 0 (reduce + (map count (:errors query)))))

(declare validate-select validate-group validate-where
         validate-order-by validate-limit validate-offset)

(defn validate
  "Check the query for any errors."
  [query]
  (if (not (:slicedef query))
    query
    (let [slicedef (:slicedef query)
          dimensions (:dimensions slicedef)
          metrics (:metrics slicedef)
          column-set (set (concat dimensions metrics))]
      (-> query
          (assoc :errors {})
          (validate-select column-set)
          (validate-group column-set dimensions)
          validate-where
          validate-order-by
          validate-limit
          validate-offset))))

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