There is old discussion (and revered code) here: https://github.com/metosin/schema-tools/issues/30
Not sure if there is a good way to solve this, but if there is, let’s do it 🙂
@nha about the original. Not sure there is anything currently. But like st/open
makes all nested maps open, there could be similar helper (or st/open
option) to make all keys optional. This way, it would not fail on missing keys. I think it would be easy to write.
well, I have a 10min, let’s try…
oh, there is already st/optional-keys
, but it’s not recursive.
yes. it would work, all the tests pass.
not sure if the new defn is a good idea, maybe it should be a parameter to st/open-schema
instead?
As long as you can compose them it shouldn’t be a problem. Or are you worried about walking the schema twice? I personally don’t mind, my schemas are fairly small and static so coercer fns can be compiled when the app starts
True, the coercers can be cached, so the double walking is ok. How does the PR look otherwise?