Is there a way how to make body optional? I've tried :body [task (s/maybe {})]
and :body [{task :- {} nil}]
which doesn't compile, so what is the right way?
@petr.mensik the first one looks right. Are you sure it doens't work?
yep, body is optional however validation fails if you pass for instance {"name" : "abc"}
complains that key is not defined in the schema
and I want to accept either nothing or any kind of map
Ah, it's (s/maybe {s/Any s/Any})
then.
Maps are closed by default on Schema (and open on Spec)
there is a also a helper spec-tools/open-schema
which makes the map-schemas open recursively.
And that applies to any number of key/vals?
yes, "any keys and any values"
cool, thank you!
In Schema, you can have 0-1 special keys on maps, {:a s/Int, s/Str s/Any}
would allow :a
and any string-keys.
np.