schema

ikitommi 2018-05-20T05:43:19.000012Z

There is old discussion (and revered code) here: https://github.com/metosin/schema-tools/issues/30

ikitommi 2018-05-20T05:44:26.000020Z

Not sure if there is a good way to solve this, but if there is, let’s do it 🙂

ikitommi 2018-05-20T05:49:23.000033Z

@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.

ikitommi 2018-05-20T05:50:15.000024Z

well, I have a 10min, let’s try…

ikitommi 2018-05-20T05:52:38.000016Z

oh, there is already st/optional-keys, but it’s not recursive.

ikitommi 2018-05-20T06:05:42.000015Z

yes. it would work, all the tests pass.

ikitommi 2018-05-20T06:09:44.000040Z

https://github.com/metosin/schema-tools/pull/46

ikitommi 2018-05-20T06:11:02.000016Z

not sure if the new defn is a good idea, maybe it should be a parameter to st/open-schema instead?

2018-05-20T11:37:35.000091Z

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

ikitommi 2018-05-20T13:09:28.000043Z

True, the coercers can be cached, so the double walking is ok. How does the PR look otherwise?