Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages / docs for registry references #418

Closed
yuhan0 opened this issue Apr 14, 2021 · 0 comments
Closed

Better error messages / docs for registry references #418

yuhan0 opened this issue Apr 14, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@yuhan0
Copy link

yuhan0 commented Apr 14, 2021

I found out mostly through experimentation and examples that the :map and :ref schemas take only qualified keys and strings as registry references (as specified by malli.core/-reference?, it turns out)

The docs don't explicitly mention this requirement though, and the error messages produced by :map could be clearer:

(malli/schema [:map {:registry {:unqualified :any}}
               :unqualified])
;; => Execution error (UnsupportedOperationException) at malli.core/-parse-entries$-parse (core.cljc:185).
;;    count not supported on this type: Keyword

(malli/schema [:map {:registry {:unqualified :any}}
               [:unqualified]])
;; => Execution error (ExceptionInfo) at malli.impl.util/-fail! (util.cljc:16).
;;    :malli.core/invalid-schema {:schema nil}

Expected behavior:

Throw a :malli.core/invalid-ref error like the :ref schema does, including the invalid key in the error map.

(malli/schema [:ref :unqualified]
  {:registry (merge (malli/default-schemas) {:unqualified :any})})
;; => Execution error (ExceptionInfo) at malli.impl.util/-fail! (util.cljc:16).
;;    :malli.core/invalid-ref {:ref :unqualified}
@ikitommi ikitommi added the enhancement New feature or request label Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants