From 801a8feb1a8cc33564e1236f194f7d061b421055 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Mon, 1 Jan 2024 12:41:57 +0200 Subject: [PATCH] fix ::m/invalid-entry printing --- src/malli/core.cljc | 2 +- src/malli/dev/pretty.cljc | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/malli/core.cljc b/src/malli/core.cljc index 64284c0e1..df73dcc11 100644 --- a/src/malli/core.cljc +++ b/src/malli/core.cljc @@ -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)) diff --git a/src/malli/dev/pretty.cljc b/src/malli/dev/pretty.cljc index c77757fae..f93f33db7 100644 --- a/src/malli/dev/pretty.cljc +++ b/src/malli/dev/pretty.cljc @@ -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