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.
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 foraandb.A possible solution would be an opt-in method, leaving the current behaviour as the default:
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.