Closed fr33m0nk closed 2 years ago
Context:
datomic.query.EntityMap
;;Would it help if the malli.core/-map-schema took an extra option for the predicate? e.g. on could just do:
(def EntityMap (m/-map-schema {:pred entity?}))
(m/validate EntityMap ...)
* `:pred` key-value is optional, just like `:lazy` and `:naked-keys`. In absence of explicit value, `map?` is used as default predicate (referred to as `pred?` in code) Usage with PR: ```clojure ;; regular usage still works just fine (m/validate (m/schema [:map [:member/id uuid?] [:member/organization [:map [:organization/id uuid?]]]]) {:db/id 409018325533822, :member/id #uuid"ff995e8b-77c0-4c03-a8a8-c5db609a2f16", :member/organization {:db/id 17592186045562, :organization/id #uuid"25dd7d64-6f83-49fe-bd36-253e985b3e00"}}) => true ;; a custom predicate fn (defn entity? [entity] (instance? datomic.query.EntityMap entity)) ;; example member entity member-entity => {:db/id 409018325533822, :member/id #uuid"ff995e8b-77c0-4c03-a8a8-c5db609a2f16", :member/organization {:db/id 17592186045562, :organization/id #uuid"25dd7d64-6f83-49fe-bd36-253e985b3e00"}} ;; validation of entity (m/validate (m/schema [:entity-map [:member/id uuid?] [:member/organization [:entity-map [:organization/id uuid?]]]] {:registry (assoc (m/default-schemas) :entity-map (m/-map-schema {:pred entity?}))}) mmm) => true
Context:
datomic.query.EntityMap
(def EntityMap (m/-map-schema {:pred entity?}))
(m/validate EntityMap ...)