-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Allow specifying allowed options? #193
Comments
@richtier @joke2k What do you think of having like this: # (env variable, list of choices, optional default value)
MY_SETTING = env.choices('MY_ENV', ['choice_1', 'choice_2', 'choice_3'], 'choice_3') Or maybe as a new kwarg instead: MY_SETTING = env.str('MY_ENV', choices=['choice_1', 'choice_2', 'choice_3'], 'choices_3')
MY_SETTING = env.int('MY_ENV', choices=[123, 456, 789, 0], 0) |
Just adding an use case which clearly would benefit from this (and would also make for a good example code snippet): the |
@sergeyklay @joke2k In case anyone wants to pick it up, would such a PR be acceptable? Seems quite a low-risk, self-contained feature with no apparent side-effects. Wdyt? @QuentinAndre11: is your code posted publicly somewhere to check? |
It would be great to detect an env var has been misconfigured by optionally providing a list of valid choices for the value.
It seems this is not currently supported.
Is this on the roadmap? I'm happy to contribute this feature.
The text was updated successfully, but these errors were encountered: