Skip to content

Commit 4767ee8

Browse files
committed
Update readme for i18n and errors->paths
1 parent 31e9407 commit 4767ee8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

README.org

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)