 (ns clj-money.schema
-  (:require [clojure.pprint :refer [pprint]])
+  (:require [clojure.pprint :refer [pprint]]
+            [clojure.string :as string])
   (:use clj-money.inflection))
 
 (def rules

    :message "must be a number"}
   {:fn #(re-find #"invalid format" (print-str %))
    :message "is not valid"}
   {:fn #(re-find #"instance\? java\.lang\.String nil" (print-str %))
    :message "is required"}])


  a user-friendly message"
  [violation]
  (or (some (fn [{f :fn m :message}]
              (when-let [result (f violation)]
                (if (seq? result)
                  (apply format m result)
                  (format m result))))
            rules)
      violation))

