Giter Site home page Giter Site logo

Comments (4)

af avatar af commented on August 26, 2024

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

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.

FreePhoenix888 avatar FreePhoenix888 commented on August 26, 2024

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 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.

af avatar af commented on August 26, 2024

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.

FreePhoenix888 avatar FreePhoenix888 commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.