Fork me on GitHub
#malli
<
2024-01-04
>
ikitommi07:01:04

qualified symbols are https://github.com/metosin/malli/pull/984 valid reference types:

(m/validate
 [:map {:registry {:user/id :int
                   "user/name" :string
                   'user/country [:enum "UA"]}}
  :user/id 
  "user/name" 
  'user/country]
 {:user/id 123
  "user/name" "Tiina"
  'user/country "UA"})
; => true

🎉 2
ikitommi10:01:27

@ben.sless draft for supporting Var Schema references: https://github.com/metosin/malli/pull/985

ikitommi10:01:23

Didn’t check how sci works with vars.

ikitommi10:01:34

beauty of Clojure:

(defn var-registry []
  (reify
    Registry
    (-schema [_ type] (if (var? type) @type)))

ikitommi10:01:31

After this, Vars would work as naked keys too, but I don’t think this has any use case, just a bonus feature.

(def description :string)

(m/validate
 [:map {:registry {:user/id :int
                   "user/name" :string
                   'user/country [:enum "UA"]}}
  :user/id
  "user/name"
  'user/country
  #'description] ;; here1
 {:user/id 123
  "user/name" "Tiina"
  'user/country "UA"
  #'description "var"}) ;; here2

Ben Sless11:01:58

Left a comment regarding my main motivation for wanting this

👌 1