Verified

Env Config Validator

A Verified Samchil module for validating runtime environment configuration with typed Zod schemas and redacted validation errors.

Store listing is live for Polar checkout. GitHub repository access is handled by the Polar-connected repository benefit after confirmed payment.

Public API

  • createEnvConfig validates input and returns typed config.
  • EnvValidationError exposes readable validation failure details.
  • booleanFromEnv, numberFromEnv, and jsonFromEnv provide common environment string conversions.

Input and schema behavior

  • Default input is process.env; tests and examples may pass a plain object.
  • Required, optional, default, enum, URL, and unknown-key behavior are delegated to the caller's Zod schema.
  • Unknown keys fail only when the caller uses a strict Zod schema.

Secret redaction

  • Default secret key detection covers common names containing secret, password/passwd, token, api key, or private key.
  • Callers may pass secretKeys to add exact string or regular expression matchers.
  • For root-level, cross-field, or JSON-parsed validation messages, secret-like raw values are redacted when they appear in the message.