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

No option to exclude keys from case conversion #625

Open
moldhouse opened this issue Dec 23, 2024 · 0 comments
Open

No option to exclude keys from case conversion #625

moldhouse opened this issue Dec 23, 2024 · 0 comments

Comments

@moldhouse
Copy link

Currently, it is not possible to specify a list of keys that should be excluded from case conversion.

In my case, this makes it hard to build a config from an Environment and a File, where some identifiers in the file are kebab-case, while other parameters are snake_case.

For example, I want a kebab-case key and a snake_case configuration:

# TOML configuration
[foo.kebab-case-key]
snake_case_configuration = "bar"
# Environment configuration
FOO__KEBAB_CASE_KEY__SNAKE_CASE_CONFIGURATION=bar

While there is a method convert_case, it is applied to all collected keys. For this example, a possible solution would be something like:

Environment::default().convert_case_exclude_keys(Case::Kebab, ["snake_case_configuration"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant