Fork me on GitHub
#malli
<
2022-02-25
>
Oliver Marks13:02:51

so still struggling with transformers not being applied, I am looking at the request chain I can see that :body-params is populated with a namespaced map, how ever in the next steps I get this

+:body-params {:object/type "test"}}

--- :request---

  nil

--- :request :reitit.ring.coercion/coerce-exceptions ---

  {}

--- :request :reitit.ring.coercion/coerce-response ---

  {}

--- :response---

  {:body {:coercion :malli,
          :errors ({:in [],
                    :message "invalid type",
                    :path [],
Seems a bit strange that the :in would be blank, I am getting this from a test which I am using to help me figure out my issue also invalid type is not over descriptive in this context seems, any tricks to getting more info from malli on what its doing, or does this help any one give me some suggestions ?

Oliver Marks13:02:03

I would also be intrested in a bit more info on this map, https://github.com/metosin/reitit/blob/198cfda00d20093f3d7b3069e5e902835c396698/modules/reitit-malli/src/reitit/coercion/malli.cljc#L110 are there any docs on what going on is :transformers the function that gets applied to produce the body-params ie is it this step which should be converting my strings to keywords based on the schema ?

Grant Horner16:02:02

Running into a weird issue: I’m getting the following report on a function call in my test suite:

{:in [1 0 :foo-id],
   :message "should be a positive int",
   :path [1 0 :foo-id],
   :schema pos-int?,
   :value 9218}
where, according to the report, the value is in fact a positive integer. The function is expecting a
[:sequential [:map [:foo-id pos-int?] [:name string?]]]
as an input, and is receiving
({:name "Foo Inc", :foo-id 9218, :type "security-id", :value 9218})
as the arg. This correctly passes the call to malli.core/validate , but is failing in my test suite for some reason

Grant Horner16:02:38

false alarm. the value is actually a biginteger. maybe the error message could be improved in these cases? perhaps including the value’s type?

Oliver Marks19:02:00

I may have had a bit of progress, I seem to be able to make it work using application/json in place of application/transit+json I was using the later as cljs-ajax drops the namespace in the keys which I was hoping to avoid. could this be a case of the flow is different for application/transit+json I did add it to the coercsion map like below.

{:transformers {:body {:default reitit.coercion.malli/default-transformer-provider
                          :formats {"application/json" reitit.coercion.malli/json-transformer-provider
                                    "application/transit+json" reitit.coercion.malli/json-transformer-provider}}