envconfig
envconfig copied to clipboard
Group missing required field errors.
Don't stop processing when an required variable is missing, instead build a list of the missing variables, and throw a single error at the end.
This change results in an error message such as
required key(s) missing values: FOO,BAR
Related to https://github.com/kelseyhightower/envconfig/issues/143
@bchapman
I don't agree.
If there is any required tag, when the value is empty, it should early return the error.
I totally agree with the change request here
It makes no sense to stop on the first error. It is just lazy.
Imagine a system with dozens of required fields. Running the server dozens of times to get the missing values from the environment is just not helpful (specially on production environments which may have a long environment variables list and modifying them may take some time between redeploys and log analysis).
This change is really simple, maintainable, doesn't hurt performance and greatly improves UX. Thanks @bchapman!