|
|
@@ -63,29 +63,30 @@
|
|
|
(->> errors
|
|
|
(group-by #(-> % :in first))
|
|
|
(map (fn [[idx errors']]
|
|
|
- {:entity (let [ent (get ent-maps idx)]
|
|
|
- (cond-> ent
|
|
|
+ (let [ent (get ent-maps idx)]
|
|
|
+ {:entity (cond-> ent
|
|
|
;; Provide additional page info for debugging
|
|
|
(:block/page ent)
|
|
|
(update :block/page
|
|
|
(fn [id] (select-keys (d/entity db id)
|
|
|
- [:block/name :block/tags :db/id :block/created-at])))))
|
|
|
- :errors errors'
|
|
|
+ [:block/name :block/tags :db/id :block/created-at]))))
|
|
|
+ :dispatch-key (->> (dissoc ent :db/id) (db-malli-schema/entity-dispatch-key db))
|
|
|
+ :errors errors'
|
|
|
;; Group by type to reduce verbosity
|
|
|
;; TODO: Move/remove this to another fn if unused
|
|
|
- :errors-by-type
|
|
|
- (->> (group-by :type errors')
|
|
|
- (map (fn [[type' type-errors]]
|
|
|
- [type'
|
|
|
- {:in-value-distinct (->> type-errors
|
|
|
- (map #(select-keys % [:in :value]))
|
|
|
+ :errors-by-type
|
|
|
+ (->> (group-by :type errors')
|
|
|
+ (map (fn [[type' type-errors]]
|
|
|
+ [type'
|
|
|
+ {:in-value-distinct (->> type-errors
|
|
|
+ (map #(select-keys % [:in :value]))
|
|
|
+ distinct
|
|
|
+ vec)
|
|
|
+ :schema-distinct (->> (map :schema type-errors)
|
|
|
+ (map m/form)
|
|
|
distinct
|
|
|
- vec)
|
|
|
- :schema-distinct (->> (map :schema type-errors)
|
|
|
- (map m/form)
|
|
|
- distinct
|
|
|
- vec)}]))
|
|
|
- (into {}))}))))
|
|
|
+ vec)}]))
|
|
|
+ (into {}))})))))
|
|
|
|
|
|
(defn validate-db!
|
|
|
"Validates all the entities of the given db using :eavt datoms. Returns a map
|