Skip to content

No option to trim whitespace from env values #768

Description

@solontsev

Currently, there is no way to trim leading and trailing whitespace from environment variable values. Also, trimming would be helpful in list separator too: APP_LIST="a, b, c" should yield to ["a", "b", "c"] with no leading spaces for a and b.

A possible solution would be an opt-in method, leaving the current behaviour as the default:

Environment::with_prefix("APP")
    .trim_values(true)
    .try_parsing(true);

The value should be trimmed before any further processing.

I prepared a PR #767 to add this feature with a bunch of tests describing the behaviour.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions