Open obeah opened 8 years ago
Yes, it was reverted on purpose. Using schema-value proved too unpredictable and broke existing code: https://github.com/metosin/schema-tools/commit/240f8a5f973d4f6b6036aebcbf110c04909bd65d
We are interested in finding a way to support this. Ideas welcome.
Some ideas here: https://github.com/metosin/schema-tools/issues/8#issuecomment-199649328
Could there be a separately special get-in-value
, which would walk over schema Records?
Perhaps. I think -value
postfix doesn't clearly indicate that Schema values would be walked over all along the path. Maybe -values
is better?
There is already get-schema-value
which walks over one level and is documented "Returns the sub-schema or sub-schemas of given schema."
. So, get-in-schema-value
could be coherent name...
Thanks. I understand the problem with "conditional", "maybe" etc. (actually will be doing some special form of get-in for my particular use case of "conditional" - it will return a union of values for all possible branches). As for "recursive" I definitely missing smth - it seems to me it would be just enough to resolve it to actual underlying schema and continue but you obviously encountered some issues with that.
@obeah It is also somewhat unpredictable with recursive:
(get-in {:a {:b (s/recursive Foo)}} [:a :b])
;; Foo
;; or (s/recursive Foo) ?
thanks, got it. It seems that for this particular case, current implementation returns recursive, not underlying schema: (get-in {:a {:b (s/recursive Foo)}} [:a :b])
But for the case when caller wants to go one or more levels deeper then it seems reasonable to resolve "recursive" to actual schema and continue. So (get-in {:a {:b (s/recursive Foo)}} [:a :b :key-in-foo]) would return schema for :key-in-foo.
Hi,
it seems recursive is not supported by get-in. Was it omitted on purpose? With small modifications it works for my use case: