Validation errors by field

24 views
Skip to first unread message

Erik Bakstad

unread,
Nov 4, 2012, 5:26:33 AM11/4/12
to clj-...@googlegroups.com
Hi, is there a build-in way to get validation errors by field? I would like the backend to return a json string, and have a backbone view set validation errors pr. input. Right now I'm doing something like:

(defn errors-by-field [model]
  (reduce (fn [so-far k]
            (if-let [e (v/get-errors k)]
              (assoc so-far k e)
              so-far)) {} (keys model)))

But since this is a normal use-case (I think?), I'm wondering if I'm missing something obvious?

BR

Erik

Chris Granger

unread,
Nov 4, 2012, 1:44:01 PM11/4/12
to clj-noir
You can get at the errors directly: @validation/*errors* - but I agree that should be baked in somewhere

Cheers,
Chris.
Reply all
Reply to author
Forward
0 new messages