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

malli.util operations do not properly deref namespaced keyword custom types #773

Open
bortexz opened this issue Oct 27, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@bortexz
Copy link

bortexz commented Oct 27, 2022

The following code blows up with invalid schema:

(defonce registry* (atom (m/default-schemas)))

(mr/set-default-registry! (mr/mutable-registry registry*))

(defn sdef
  "Defines a new schema in mutable [[registry*]]."
  ([type schema] (swap! registry* assoc type schema) schema)
  ([type props schema] (swap! registry* assoc type [:schema props schema]) schema))

(sdef ::thing-nested2 int?)
(sdef ::thing-nested (mu/optional-keys [:map ::thing-nested2]))
(sdef ::thing (mu/optional-keys [:map ::thing-nested]))

(mu/update ::thing ::thing-nested (fn [s] (mu/required-keys s [::thing-nested2])))
=>
; :malli.core/invalid-schema {:schema nil}
; Evaluation of file malli.clj failed: class clojure.lang.Compiler$CompilerException

schemas should be properly deref'd so that the above code works properly

@dvingo
Copy link
Contributor

dvingo commented Nov 20, 2022

I just ran into this and wanted to add the current workaround

from :https://clojurians.slack.com/archives/CLDK6MFMK/p1666794918780899

(mu/update (get @registry* ::thing) ::thing-nested (fn [s] (mu/required-keys s [::thing-nested2])))

or:

(mu/update-in ::thing [0 ::thing-nested] (fn [s] (mu/required-keys s [::thing-nested2])))

@vharmain vharmain added the bug Something isn't working label Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants