Is there any way to specify a default value for an optional query parameter to a resource?
@fiddlerwoaroof I don’t think this is supported in the Schema itself, so you’d have to do this using normal Clojure is my guess
Maybe it could be done as part of coercion
Possibly. RelaxNG argued that validation and defaulting should remain separate
Not sure
schema-tools has a coercion matcher & wrapped type to handle the defaults:
(require '[schema-tools.core :as st])
(require '[schema-tools.coerce :as stc])
(stc/coerce
{:x nil}
{:x (st/default s/Int 1)
:y (st/default s/Int 2)}
stc/default-matcher)
; => {:x 1, :y 2}
does yada provide any way to adjust the coercion that happens? Or would I have to do this, once I get the query parameters back?
You can do this with a yada parameter
Is there an example of this?
I've forgotten the name unfortunately.
And I'm not at a keyboard.