Skip to content

v7.0.0 beta 1

Pre-release
Pre-release
Compare
Choose a tag to compare
@af af released this 25 Jan 02:46

Version 7 of Envalid is finally ready for public consumption. Thanks to @KATT and @SimenB for their help and feedback on the (long-running) PR.

Please try it out in your project with npm install [email protected] or yarn add [email protected] and report any bugs, errors, or unexpected behavior (after reading the changes below!). A stable release will follow once any bugs are shaken out.

  • All code rewritten in TypeScript
  • Removed all runtime dependencies (check out the difference in code size)
  • The mode-formerly-known-as-strict is removed, and its behavior is enabled by default. This means:
    • The env object will only contain the env vars that were specified by your validators.
    • Any attempt to access an invalid/missing property on the env object will cause a thrown error.
    • Any attempt to mutate the cleaned env object will cause a thrown error.
      You can still opt-out of strict mode by disabling the strictProxyMiddleware, but it's not
      recommended (see "Custom Middleware", below).
  • The dotenv package is no longer shipped as part of this library. You can easily use it directly
    by installing it and running require('dotenv').config() before you invoke envalid's cleanEnv()
  • The transformer validator option is gone, replaced by the ability to add custom middleware
  • The host and ip validators are now slightly less exhaustive. If you need these to be airtight, use
    your own custom validator instead
  • When you try to access an invalid property on the cleaned env object, the error will no longer
    suggest an env variable that you may have intended. You can re-implement the old behavior with a custom
    middleware if you wish
  • NODE_ENV support is now less opinionated, and an error is no longer thrown if a value other
    than production/development/test is passed in. You can provide your own validator for NODE_ENV
    to get exactly the behavior you want. The isDev, isProduction, etc properties still work as
    before, and are implemented as middleware so you can override their behavior as needed.