Skip to content

Commit ba16cf7

Browse files
committed
use recursion to remove nested named errors
1 parent 765cda3 commit ba16cf7

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject com.yetanalytics/xapi-schema "0.1.0"
1+
(defproject com.yetanalytics/xapi-schema "0.1.1"
22
:description "Clojure(script) Schema for the Experience API v1.0.3"
33
:url "https://github.com/yetanalytics/xapi-schema"
44
:license {:name "Eclipse Public License"

spec/cljx/xapi_schema/schemata/util_spec.cljx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,19 @@
239239
"enum" "Not in #{\"foo\" \"bar\" \"baz\"}: quxx"
240240
"one" ["Not present: at least one string"]}
241241
(errors->data @err))))
242-
(context "given some xapi validation cases"
242+
(context "given some xapi validation cases"
243+
(with bad-xapi (errors->data
244+
(s/check json/Statement
245+
(assoc d/long-statement
246+
"actor"
247+
{"mbox" "mailto:milt@yetanalytics.com"
248+
"objectType" "NotAnAgent"}))))
243249
(it "parses an agent objectType error"
244250
(should-not-throw
245-
(errors->data
246-
(s/check json/Statement
247-
(assoc d/long-statement
248-
"actor"
249-
{"mbox" "mailto:milt@yetanalytics.com"
250-
"objectType" "NotAnAgent"})))))))
251+
@bad-xapi))
252+
(it "coerces the errors to strings"
253+
(should= {"actor" {"objectType" "Not Agent: NotAnAgent"}}
254+
@bad-xapi))))
251255
(describe
252256
"errors->paths"
253257
(it "returns a map"

src/cljx/xapi_schema/schemata/util.cljx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
(if (named-error? node)
149149
(let [name #+clj (.name node) #+cljs (.-name node)
150150
error #+clj (.error node) #+cljs (.-error node)]
151-
error)
151+
(strip-named error))
152152
node))
153153

154154
(defn errors->data [e & [ltag]]

0 commit comments

Comments
 (0)