This commit is contained in:
2024-11-04 21:17:28 -08:00
parent 71d7461eb9
commit 61f043ddae
3 changed files with 47 additions and 26 deletions

View File

@@ -285,7 +285,7 @@
(def pull-transformer
(mt2/transformer {:decoders
{:entity-map
{:compile (fn [schema _]
{:compile (fn [schema g]
(let [pull-expr (:pull (mc/properties schema))]
(if pull-expr
(fn pull-data [m]
@@ -469,7 +469,14 @@
main-transformer)))
(catch Exception e
(alog/warn ::validation-error :error e)
(alog/warn ::validation-error
:error e
::errors (-> e
(ex-data)
:data
:explain
(me/humanize {:errors (assoc me/default-errors
::mc/missing-key {:error/message {:en "required"}})})))
(throw (ex-info (->> (-> e
(ex-data)
:data
@@ -643,7 +650,8 @@
{:entity-id entity-id
:entity-map
(mc/-simple-schema {:type :entity-map
:pred map?})
:pred map?
:type-properties { :error/message "required"}})
#_[:map {:name :entity-map} [:db/id nat-int?]]}))
(comment
@@ -666,15 +674,21 @@
(handler (update-in request [:route-params] merge route-params))))
(defn check-allowance [account-id allowance-key]
(let [allowance (allowance-key (dc/pull (dc/db conn) '[{[:account/invoice-allowance :xform iol-ion.query/ident] [:db/ident]
(let [account-id (if (map? account-id)
(:db/id account-id)
account-id)
allowance (allowance-key (dc/pull (dc/db conn) '[{[:account/invoice-allowance :xform iol-ion.query/ident] [:db/ident]
[:account/vendor-allowance :xform iol-ion.query/ident] [:db/ident]
[:account/default-allowance :xform iol-ion.query/ident] [:db/ident]}]
account-id))]
(not= :allowance/denied
allowance)))
(defn check-location-belongs [location account]
(let [account-location (pull-attr (dc/db conn) :account/location account)]
(defn check-location-belongs [location account-id]
(let [account (if (map? account-id)
(:db/id account-id)
account-id)
account-location (pull-attr (dc/db conn) :account/location account)]
(when (and (seq account-location)
(not= location
account-location))