Permalink
Browse files

make noir.validation/errors? return correctly when asked without fields

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
ibdknox committed Sep 9, 2011
1 parent 47d4214 commit 9749e3c110d8ba457217eaa95e1e6d7d47f69f6c
Showing with 6 additions and 2 deletions.
  1. +3 −1 src/noir/util/test.clj
  2. +3 −1 src/noir/validation.clj
View
@@ -3,6 +3,7 @@
(:use clojure.test)
(:require [noir.server :as server]
[noir.session :as session]
+ [noir.validation :as vali]
[noir.cookies :as cookies]
[noir.options :as options]))
@@ -13,6 +14,7 @@
"Executes the body within the context of Noir's bindings"
[& body]
`(binding [options/*options* options/default-opts
+ vali/*errors* (atom {})
session/*noir-session* (atom {})
cookies/*new-cookies* (atom {})
cookies/*cur-cookies* (atom {})]
@@ -47,4 +49,4 @@
the request within the context of all middleware."
[route & [params]]
(let [handler (server/gen-handler)]
- (handler (make-request route params))))
+ (handler (make-request route params))))
View
@@ -70,7 +70,9 @@
"For all fields given return true if any field contains errors. If none of the fields
contain errors, return false"
[& field]
- (some not-nil? (map get-errors field)))
+ (if-not (seq field)
+ (not (empty? @*errors*))
+ (some not-nil? (map get-errors field))))
(defn on-error
"If the given field has an error, execute func and return its value"

0 comments on commit 9749e3c

Please sign in to comment.