mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
feat: support humanize options
This commit is contained in:
parent
9d88d92241
commit
a4576cc622
1 changed files with 3 additions and 2 deletions
|
|
@ -128,7 +128,7 @@
|
|||
([]
|
||||
(create nil))
|
||||
([opts]
|
||||
(let [{:keys [transformers lite compile options error-keys encode-error] :as opts} (merge default-options opts)
|
||||
(let [{:keys [transformers lite compile options error-keys encode-error humanize-opts] :as opts} (merge default-options opts)
|
||||
show? (fn [key] (contains? error-keys key))
|
||||
;; Query-string-coercer needs to construct transfomer without strip-extra-keys so it will
|
||||
;; use the transformer-provider directly.
|
||||
|
|
@ -188,7 +188,8 @@
|
|||
(-open-model [_ schema] schema)
|
||||
(-encode-error [_ error]
|
||||
(cond-> error
|
||||
(show? :humanized) (assoc :humanized (me/humanize error {:wrap :message}))
|
||||
(show? :humanized) (assoc :humanized (me/humanize error (cond-> {:wrap :message}
|
||||
humanize-opts (merge humanize-opts))))
|
||||
(show? :schema) (update :schema edn/write-string opts)
|
||||
(show? :errors) (-> (me/with-error-messages opts)
|
||||
(update :errors (partial map #(update % :schema edn/write-string opts))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue