Fork me on GitHub
#malli
<
2022-07-28
>
nonrecursive19:07:26

hi all! i’m using reitit with malli for parameter coercion, and I have a schema with default values for some parameters, but those default values aren’t being added. has anyone else run into this?

nonrecursive19:07:29

my router looks like this:

(def router
  (rr/router routes
             {:data {:coercion   reitit.coercion.malli/coercion
                     :middleware route-middleware}}))

pppaul22:07:15

there is a default values transformer

nonrecursive22:07:54

I discovered the reason, it was because it had {:optional? true} in the options

Noah Bogart20:07:52

is it possible to say "this is either a set or the specific keyword :bypass "?

Noah Bogart20:07:41

realized my mistake immediately, lol. the answer is: [:or set? [:enum :bypass]]

Mateo Difranco23:07:17

What would be the best way of handling multiple possibilities of a map inside a schema, based on a top level keyword? Maybe I can explain myself better with some examples, let's say I have something like this:

{:something "test"
 :type :a
 :deep {:depends 3}}
and
{:something "test"
 :type :b
 :deep {:another [1 2]}}
So, based on :type, I'm expecting different things in :deep. This seems to be a good case for :multi, given it allows using a function for dispatch. But the dispatch function would take the :deep map, not the top level whole map. I have a work-around for this, but it's quite ugly and I'm wondering if there's a better way.