New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@comment-labs/assert-env

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comment-labs/assert-env

Type-safe environment variable validation

latest
npmnpm
Version
1.0.0-beta.6
Version published
Maintainers
1
Created
Source

@comment-labs/assert-env

Type-safe environment variable validation.

Installation

pnpm add @comment-labs/assert-env

Usage

import { assertEnv } from '@comment-labs/assert-env'

const env = assertEnv(
  {
    ACCOUNT_ID: 'string',
    PORT: 'number'
  },
  {
    optional: {
      DEBUG: 'boolean'
    },
    envFile: true
  }
)

env.ACCOUNT_ID
env.PORT
env.DEBUG

Set envFile: true to load .env into process.env before validation, or pass a path such as envFile: '.env.development' to load a specific file. Omit the option to leave dotenv loading to the caller.

Supported Types

  • string
  • number
  • boolean

Validation Behavior

  • Required variables must be set.
  • string values must not be empty or whitespace-only.
  • number values are trimmed before parsing and support floats and negative numbers.
  • boolean values accept true, false, 1, 0, yes, and no, case-insensitively.
  • Optional variables are omitted when missing or blank.
  • Invalid variables are reported together in a single error.

License

Apache-2.0

FAQs

Package last updated on 03 Oct 2026

Related posts