Commits

Steve Losh committed 285c8ac

Minor cleanup.

Comments (0)

Files changed (4)

src/red_tape/cleaners.clj

 
   (def us-states #{\"NY\" \"PA\" \"OR\" ...})
 
-  (defform address-form {}
-    ...
-    :state [#(choices us-states %
-                      \"Please enter a valid US state.\")])
+    (defform address-form {}
+      ...
+      :state [#(choices us-states % \"Please enter a valid US state.\")])
 
   Not limited to strings, so you can parse the input into something else and
   then check for those with choices if you want.
 
 (defn to-boolean
   "Convert a string to a boolean.
-  
+
   The following strings are considered true (case-insensitive):
 
     1
     true
     t
-  
+
   The following strings are considered false (case-insensitive):
 
     0

src/red_tape/core.clj

 (ns red-tape.core
-  (:require [slingshot.slingshot :refer [try+ throw+]]))
+  (:require [slingshot.slingshot :refer [try+]]))
 
 
 (defmacro map-for
                       :let [[value error] (clean-data data cleaners)]]
                   [k value error])
         values (map-for [[k v _] results]
-                         [k v])
+                        [k v])
         errors (map-for [[k _ e] results
                          :when (not (nil? e))]
                         [k e])]

test/red_tape/cleaners_test.clj

 
 (defmacro throws [& body]
   `(~'is (not (nil? (try+ (do ~@body nil)
-                        (catch Object e# e#))))))
+                          (catch Object e# e#))))))
 
 (defmacro are-bad [msg test-fn & values]
   `(testing ~msg
      ~@(map (fn [v]
-         `(throws (~test-fn ~v))) values)))
+              `(throws (~test-fn ~v))) values)))
 
 
 ; Strings

test/red_tape/core_test.clj

   (testing
     "forms can take string keys"
     (is (= (:results (number-form {"n" "10"}))
-        {:n 10})))
+           {:n 10})))
 
   (testing
     "successful forms return results"