Skip to content

Commit

Permalink
docs for :invalid-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Jan 2, 2024
1 parent 4e7738f commit a71b86a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/malli/dev/pretty.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
(-> [:group (v/-color :title "malli: " printer) text]
(v/-print-doc printer)))

(defn -ref-text [printer]
[:group "Reference should be one of the following:" :break :break
"- a qualified keyword, " (v/-visit [:ref :user/id] printer) :break
"- a qualified symbol, " (v/-visit [:ref 'user/id] printer) :break
"- a string, " (v/-visit [:ref "user/id"] printer)])

;;
;; formatters
;;
Expand Down Expand Up @@ -64,6 +70,12 @@
#?(:cljs (v/-block "Function Var:" (v/-visit fn-name printer) printer)) :break :break
(v/-block "More information:" (v/-link "https://cljdoc.org/d/metosin/malli/CURRENT/doc/function-schemas" printer) printer)]})

(defmethod v/-format ::m/invalid-ref [_ {:keys [ref]} printer]
{:body [:group
(v/-block "Invalid Reference" (v/-visit [:ref ref] printer) printer) :break :break
(v/-block "Reason" (-ref-text printer) printer) :break :break
(v/-block "More information:" (v/-link "https://cljdoc.org/d/metosin/malli/CURRENT" printer) printer)]})

(defmethod v/-format ::m/invalid-schema [_ {:keys [schema form]} printer]
(let [proposals (seq (me/-most-similar-to #{schema} schema (set (keys (mr/schemas m/default-registry)))))]
{:title "Schema Creation Error"
Expand Down

0 comments on commit a71b86a

Please sign in to comment.