Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set mapping keys to "decoded" when custom unmarshaler is used #426

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Sep 24, 2024

  1. decode: add (failing) test for undecoded fields in a struct

    This commit adds a failing test for the scenario decribed in issue
    BurntSushi#425
    mvo5 committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    e4d6f99 View commit details
    Browse the repository at this point in the history
  2. decode: set all keys under a mapping with custom marshaler decoded

    This is a naive fix for the issue of custom unmarshal and marking
    keys as "decoded". It simply assumes that if there was a custom
    unmarshal for a mapping type all keys got handlded by the custom
    unmarshal code.
    
    This might be too naive but it seems reasonable and it also seems
    we would need a richer interface for a custom unmarshal that gives
    access to `MetaData` if we want to be more fine grained.
    mvo5 committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    70d427d View commit details
    Browse the repository at this point in the history

Commits on Sep 26, 2024

  1. decode: expand test and mark fields decoded recursively

    This commit expands the test `TestDecodeCustomStructMarkedDecoded`
    so that nested data is also tested (thanks to  Martin Tournoij).
    
    This lead to an update of the code to also mark all nested keys as
    decoded when a custom `UnmarshalTOML(data any)` interface is used.
    
    It is the job of the implemenator of the UnmarshalTOML() to ensure
    everything is decoded. An alternative would be to provide a new
    `UnmarshalTOMLWithMetadata(data any, md *MetaData)` inteface that
    would allow the implementaor of the custom unmarshaller to mark
    fields as decoded. But it's unclear if that is needed because
    a UnmarshalTOML() can already error if it "sees" unexpected or
    missing data.
    mvo5 committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    8ff4571 View commit details
    Browse the repository at this point in the history