Comments (4)
desc
and example
are mainly intended for the error message when the value is missing or invalid. So in this case:
cleanEnv({
SOME_KEY: envalid.json({ desc: 'this is a description', example: 'example val' }),
})
If this key is missing you'll get:
![Screenshot 2024-03-16 at 09 27 03](https://private-user-images.githubusercontent.com/25241/313417407-b191a069-046d-4d8a-b624-6eb86150f3bc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgyNjc1NjgsIm5iZiI6MTcxODI2NzI2OCwicGF0aCI6Ii8yNTI0MS8zMTM0MTc0MDctYjE5MWEwNjktMDQ2ZC00ZDhhLWI2MjQtNmViODYxNTBmM2JjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEzVDA4Mjc0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVkZGNlMmU2MTZiNzU5N2I5ZTg2OWE0MWQxMmM3MmZhZjRiMGI4ZGRjYmIwMTk1Y2QzMDc5ZWQ1MzE4YjE3MDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.oTMcUEThVTL2OjZQnbbBoYV7mlH2MEgWAlEQ5V57GhE)
That said, you could surface this information in other ways in your app, but it's mostly intended for helpful error messages. Hope that makes sense!
from envalid.
desc
andexample
are mainly intended for the error message when the value is missing or invalid. So in this case:cleanEnv({ SOME_KEY: envalid.json({ desc: 'this is a description', example: 'example val' }), })If this key is missing you'll get:
That said, you could surface this information in other ways in your app, but it's mostly intended for helpful error messages. Hope that makes sense!
So desc and example for an env that has default value (optional env) are useless?
from envalid.
Yeah they are kind of useless in that case currently, unless you expose them in some other way.
One change we could make is to include the desc/example values in the error message when an invalid value is passed in as well, then they'd still be useful if there was a default value and an invalid runtime env var
from envalid.
Yeah they are kind of useless in that case currently, unless you expose them in some other way.
One change we could make is to include the desc/example values in the error message when an invalid value is passed in as well, then they'd still be useful if there was a default value and an invalid runtime env var
I currently use envs the same way as nextjs do
You have .env as template where envs are specified without specific values
And if you want to use it you should create .env.local
But in this case I need to write there whether an env is optional or not. It would be incredible if we do not need to repeat the same description and info whether env is optional in two places: env files itself, code where envalid is used
Also when people do not have such .env templates the current behavior is uncomfortable, you pass one variable and see that another is required, you pass it and now another variable is required. It would be good to see all the envs that are not passed and should be passed!
Thank you for this library anyway, it helps a lot anyway!
from envalid.
Related Issues (20)
- Add parse options to str() HOT 1
- array validator HOT 1
- 7.3.0 breaking change? HOT 11
- Add option to load validator specs from .example.env file HOT 1
- Access value of env object by name HOT 1
- envalid in react-native for preview crashes without giving description of missing env HOT 2
- testOnly setting variable to Symbol instead of failing HOT 5
- Pick from validators HOT 2
- str({ devDefault: undefined }) generates an incorrect type HOT 2
- Require environment variables only if `NODE_ENV` is not set to `test` HOT 2
- Skipping env var validation in tests HOT 1
- Prevent process exit during tests HOT 1
- makeExactValidator is not exported HOT 1
- Combine envalid with Docker secrets
- Issue with envalid in test. HOT 1
- Typescript, typing the environment variables returns never HOT 1
- Waiting for an async reporter callback HOT 3
- Add a warn option
- devDefault does not work when NODE_ENV is undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from envalid.