Fork me on GitHub
#malli
<
2023-10-30
>
Abhijit Kumbhar18:10:16

Hi I am new to malli. Could someone please help me in defining schema for below sample payload- here "some-dynamic-value" is dynamic string value { "some-dynamic-value": { "test": 0.07041698796202, "test2":1} }

skynet18:10:19

you could try

[:map-of {:size 1} :string [:map ["test" :double] ["test2" :int]]]

Abhijit Kumbhar18:10:46

Thank you @U0DSU64Q1 - I will try this.

Abhijit Kumbhar19:10:48

@U0DSU64Q1 - I tried this , I am not getting any error but getting 200 OK with empty response {}

Abhijit Kumbhar18:10:09

Also need help in defining schema for dynamic payload to same endpoint, my endpoint accepting two types of payload below, how can I define final schema? (def payload1 [:map [:test [:vector :int]] [:abc :string] [:params [:map [:one :string] [:two :string] [:three :string] ]]]) (def payload2 [:map [:test [:vector :int]] [:abc :string] [:params [:map [:testing :string] [:start_month :string] [:gender :string] ]]])

skynet18:10:01

use [:or payload1 payload2]

Abhijit Kumbhar18:10:53

like this?

(def final
 (malli.core/schema
  [:or payload1 payload2])
 )

👍 1