one could ask (methods multimethod)
to verify that when app is created, all things are bound. But still, configuration via multimethods is imperative, opposed of purely functional transformation of a single (admittedly, huge) configuration map. I think data is the way to go at the lowest level anyway, there could be helpers on top. Letβs draft something and see how they look like
totally agree on the approach of huge config-map with helpers on top.
@ikitommi hate to bother you more, but there is one thing I cannot figure out:
Given the code https://gist.github.com/slipset/016b6f4ebb10fea8e596221ed638302d
Whenever I POST an invalid date here, I get an error from Muuntaja.
I'm quite certain that this is on the request coercion.
I would have expected this to give me a spec error.
I can reproduce this on outbound as well:
I'll check that out after lunch.
appreciated.
Enjoy the mustamakkara π
@slipset if the spec-coercion fails, the result fails to serialize. Root cause is that we are returning the Spec :problems
over the wire and the :pred
can be anything - here itβs (partial instance? DateTime)
which fails to serialize. Wrapping the :pred
to str
should make the errors correct. Here, it would be:
{:spec "(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:compojure.api.coercion.erik/id :compojure.api.coercion.erik/name :compojure.api.coercion.erik/date]), :type :map, :keys #{:date :name :id}, :keys/req #{:date :name :id}})",
:problems [{:path ["date"],
:pred "(clojure.core/partial clojure.core/instance? org.joda.time.DateTime)",
:val "lol",
:via ["compojure.api.coercion.erik/id-name-date" "compojure.api.coercion.erik/date"],
:in ["date"],
:reason "FAIL"}],
:type "compojure.api.exception/response-validation",
:coercion "spec",
:value {:id 1, :name "foo", :date "lol"},
:in ["response" "body"]}
will push a fix soon.
Nice!
I'm just happy it wasn't my fault π
@slipset japanese π fix now in [metosin/compojure-api "2.0.0-alpha9"]
. Also, keyword specs are not memoized in coercion, should remove odd behavior if specs are redefined in dev.
Thanks alot. Will check out tomorrow.