   [tag ve-pairs]
   `(do
      (vld/clear-errors!)
-     ~@(map #(macroexpand (list 'create-rule tag %)) ve-pairs)
+     ~@(map #(list 'create-rule tag %) ve-pairs)
      (not (vld/errors? ~tag)))
   )
 

    [noir.validation :as vld]
    [ombs.db :as db]
    [clojure.pprint :refer [pprint]]
    ))

(def- errors
  {
   :event {
           :empty-name      "Event name should not be empty"

           :unexist         "Event does not exist!"      
           :finished        "Event is history."
           }
   :register {
              :short-pass      "Password should be longer than 7 chars"  
              :notmatch-pass   "Password doesn't match"                        
              }
   :user {
          :empty-name "Username can't be empty"
          :not-found "User not found" 
          :exists "Username already used!"  
          }
   :login {
           :invalid "Incorrect Login or password"
           }
   } 
  )

(defn- message [ & tgs ] (get-in errors (vec tgs)))

(defn errors-string
  ([] (reduce str (map #(str "|" % "|") (vld/get-errors))))
  ([tags] (reduce str (map #(str "|" % "|") (vld/get-errors tags)))
   ))

(defmacro create-rule [tag data]
  `(vld/rule ~@(list (first data)) [~tag ~(last data)] )
