File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,8 +100,18 @@ You can use the =errors->data= fn to coerce errors into nested data that looks l
100100(let [bad-statement (-> statement
101101 (dissoc "actor")
102102 (assoc "id" 123)]
103- (xs/errors->data (xs/statement-checker bad-statement))))
104- ;; => {"actor" "Missing", "id" "Not a string: 123"}
103+ (xs/errors->data (xs/statement-checker bad-statement :en)))) ;; ltag is optional, defaults to :en
104+ ;; => {"actor" "Missing required key", "id" "Not a string: 123"}
105+ #+END_SRC
106+
107+ If you want a map of errors to their paths in the nested data, use =errors->paths=:
108+
109+ #+BEGIN_SRC clojure
110+ (let [bad-statement (-> statement
111+ (dissoc "actor")
112+ (assoc "id" 123)]
113+ (xs/errors->paths (xs/statement-checker bad-statement :en))))
114+ ;; => {"Missing required key" ["actor"], "Not a string: 123" ["id"]}
105115#+END_SRC
106116
107117**** Use SubSchemata
You can’t perform that action at this time.
0 commit comments