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

Validation only happens one field at a time #56

Closed
robertlagrant opened this issue Jan 13, 2019 · 3 comments · Fixed by #94
Closed

Validation only happens one field at a time #56

robertlagrant opened this issue Jan 13, 2019 · 3 comments · Fixed by #94

Comments

@robertlagrant
Copy link

Currently, with the following code:

from environs import Env
env = Env()
var1 = env("VAR1")
var2 = env("VAR2")

If both env vars are missing, environs will simply display:

environs.EnvError: Environment variable "VAR1" not set

And only when that's set will it display the second error.

It'd be great to have it validate as far as possible all the required environment variables, perhaps with a manual flagging of when to start and stop such a process:

from environs import Env
env = Env(eager=False)
var1 = env("VAR1")
var2 = env("VAR2")
var3 = env.int("VAR3")
env.read()

environs.EnvError: Environment variables invalid: {"VAR1": "missing", "VAR2": "missing", "VAR3": "wrong type"]. 
@sloria
Copy link
Owner

sloria commented Jan 14, 2019

Interesting idea. We are already generating a marshmallow schema from all the parsed envvars, so this might be straightforward.

I'm open to this if it doesn't add too much complexity. PRs welcome.

@sloria
Copy link
Owner

sloria commented Jul 16, 2019

I took a stab at this in #94. @robertlagrant Can you take a look at the API and let me know what you think?

@robertlagrant
Copy link
Author

robertlagrant commented Oct 17, 2019

@sloria I missed this in my giant numbers of Github notifications! Apologies for the large delay.

In fact, I was actually just about to fork to implement and saw this. I've had a play and it looks great to me.

@sloria sloria closed this as completed in #94 Nov 3, 2019
sloria added a commit that referenced this issue Nov 3, 2019
* Add API for deferred validation

close #56

* Document deferred validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants