Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

env-vars-validator

Package Overview
Dependencies
Maintainers
1
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-vars-validator

A library who will validate your environment variables from AJV schema.

  • 1.2.49
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
207
decreased by-47.99%
Maintainers
1
Weekly downloads
 
Created
Source

Maintainability Test Coverage npm npm Snyk Vulnerabilities for npm package NPM

env-vars-validator

A library who will validate your environment variables from AJV schema.

Usage

const { validateEnv } = require("env-vars-validator")

validateEnv(
  {
    NODE_ENV: { type: 'string' },
    PORT: { type: 'integer' },
  },
  {
    requiredProperties: ['NODE_ENV'],
  },
);

API

validateEnv(schema, options?)

Return: void

Able to validate env var from Ajv Properties Fields.

Options

Field NameTypeDefaultDescription
requiredPropertiesstring[][]Indicate if field is required (More Information : JSON Schema Required)
coercevarsbooleantrueIndicate if fields will be cast to type (Example: NODE_ENV will be cast to number in our usage example)

currentEnv()

Default: development

Return: Boolean

Return current NODE_ENV without space and in lowercase format

isProductionEnv()

Return: Boolean

Return if NODE_ENV is equal to production

isPreproductionEnv()

Return: Boolean

Return if NODE_ENV is equal to preproduction

isStagingEnv()

Return: Boolean

Return if NODE_ENV is equal to staging

isDevelopmentEnv()

Return: Boolean

Return if NODE_ENV is equal to development

isTestEnv()

Return: Boolean

Return if NODE_ENV is equal to test

isDeployedEnv()

Return: Boolean

Return if NODE_ENV is not equal to development and to test

Maintain

This package use TSdx. Please check documentation to update this package.

FAQs

Package last updated on 24 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc