Skip to content

Commit

Permalink
fix ::m/invalid-entry printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Jan 1, 2024
1 parent ebafcb5 commit 801a8fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
(if (== n 1)
(if (and (-reference? e0) naked-keys)
(-parse-ref-vector1 e e0)
(-fail! ::invalid-entry {:entry ea}))
(-fail! ::invalid-entry {:entry e}))
(let [e1 (aget ea 1)]
(if (== n 2)
(if (and (-reference? e0) (map? e1))
Expand Down
12 changes: 8 additions & 4 deletions src/malli/dev/pretty.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@
(v/-block "More information:" (v/-link "https://cljdoc.org/d/metosin/malli/CURRENT" printer) printer)]}))

(defmethod v/-format ::m/invalid-entry [_ {:keys [entry]} printer]
{:title "Schema Creation Error"
:body [:group
(v/-block "Invalid Entry" (v/-visit (vec entry) printer) printer) :break :break
(v/-block "More information:" (v/-link "https://cljdoc.org/d/metosin/malli/CURRENT" printer) printer)]})
(let [wrap (if (sequential? entry) vec vector)
wrapped (wrap entry)
example (cond-> wrapped (= 1 (count wrapped)) (conj :any))]
{:title "Schema Creation Error"
:body [:group
(v/-block "Invalid Entry" (v/-visit entry printer) printer) :break :break
(v/-block "Did you mean" (v/-visit example printer) printer) :break :break
(v/-block "More information:" (v/-link "https://cljdoc.org/d/metosin/malli/CURRENT" printer) printer)]}))

;;
;; public api
Expand Down

0 comments on commit 801a8fe

Please sign in to comment.