Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Calling "decode" from hooks #298

Open
vincentbernat opened this issue Jul 30, 2022 · 1 comment
Open

Calling "decode" from hooks #298

vincentbernat opened this issue Jul 30, 2022 · 1 comment

Comments

@vincentbernat
Copy link

vincentbernat commented Jul 30, 2022

Hey!

Let's suppose I have a customer container acting a bit like a map and I provide a hook to decode it. For the hook to convert a map to the appropriate container, it would need to be able to call back decode() for the values. It seems this is not possible with the current hooks. It would be nice to be able to expose decode() to the hooks for them to call it back to decode nested values.

With YAML's Unmarshaler interface, a possibility would be to decode the container as a map, then transform this map into the final container. I don't think that's something possible with mapstructure, as I don't have access to the original decoder configuration.

@wrouesnel
Copy link

+1 for this I just ran into this problem. If you implement a custom hook so you can do something like a discriminated union then ideally you'd like to be able to use the original decoder instance for the step.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants