Skip to content

v2: Support Zod Mini; Remove dotenv & dotenv-expand; Improve Logging & Functionality - #189

Merged
noahtigner merged 17 commits into
mainfrom
feature/v2
Dec 2, 2025
Merged

v2: Support Zod Mini; Remove dotenv & dotenv-expand; Improve Logging & Functionality#189
noahtigner merged 17 commits into
mainfrom
feature/v2

Conversation

@noahtigner

@noahtigner noahtigner commented Nov 26, 2025

Copy link
Copy Markdown
Owner

Changes

  • Add support for Zod Mini
  • Remove dotenv peer dependency; replacing with Node's new process.loadEnvFile
  • Remove dotenv-expand peer dependency; replacing with streamlined version of its core functions
  • Made the envPath parameter optional. If not provided, no file is read, and only process.env is validated
  • Improve how field .meta is logged (title, description, and examples supported)
  • Improve how schema is validated and field types are allowed/disallowed
  • Refactor the codebase to improve readability and maintainability
  • Update README.md with new instructions and examples
  • Updated tests to cover new functionality and edge cases
  • Add CHANGELOG.md

Example Output

Screenshot 2025-11-25 at 6 32 01 PM Screenshot 2025-11-25 at 6 32 28 PM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces version 2.0.0 of validate-env-vars with significant architectural changes and new functionality. The package now supports both Zod v4 Classic and Zod Mini, removes external dependencies (dotenv and dotenv-expand), and implements native environment variable loading and expansion using Node.js built-in features.

Key Changes:

  • Adds Zod Mini support by migrating to zod/v4/core imports and updating type validation logic
  • Replaces dotenv/dotenv-expand with custom implementation using Node's process.loadEnvFile() and custom expansion logic
  • Makes envPath parameter optional, allowing validation of process.env without loading a file

Reviewed changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
package.json Bumped to v2.0.0; removed dotenv dependencies; updated peer dependencies to support Zod ^4.0.0
package-lock.json Removed dotenv and dotenv-expand packages from lock file
tsconfig.json Changed target to "esnext"; added "local.ts" to exclusions
eslint.config.js Streamlined ESLint configuration; separated source and test file linting rules
.gitignore Added local.ts and .git to ignore list
src/schemaTypes.ts Completely rewritten to use Zod v4 core types; removed custom env* helper functions
src/validateInput.ts Added comprehensive field type validation for Zod v4; moved validation logic from index; added isValidFieldType function
src/logParseResults.ts Enhanced logging with metadata support (title, description, examples); added helper functions for parsing metadata
src/loadEnvVars.ts New file implementing custom env file loading with variable expansion (replaces dotenv/dotenv-expand)
src/index.ts Simplified main entry point; refactored to use new validation and loading functions
src/constants.ts Removed ALLOWED_TYPE_NAMES array; added HINT_SYMBOL constant
tests/validateInput.test.ts Expanded test coverage for field type validation; added comprehensive test table
tests/schemaTypes.test.ts File deleted (helper functions removed from main API)
tests/logParseResults.test.ts Updated tests for new logging format; added tests for metadata parsing
tests/loadEnvVars.test.ts New test file for env loading and expansion functionality
tests/jest.setup.ts Added mock for process.loadEnvFile; improved test environment setup
tests/index.test.ts Updated integration tests for new API; removed dotenv-specific tests
tests/compatibility.test.ts New test file verifying Zod Classic and Zod Mini compatibility
tests/.env.test Renamed variables with TEST_ prefix; added more test cases
README.md Updated documentation with new usage examples and schema recipes; fixed typo in function name
CHANGELOG.md New file documenting version history and changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread __tests__/loadEnvVars.test.ts Outdated
Comment thread CHANGELOG.md Outdated
Comment thread src/loadEnvVars.ts
Comment thread src/loadEnvVars.ts
Comment thread README.md Outdated
Comment thread package.json
Comment thread README.md
Comment thread __tests__/jest.setup.ts Outdated
Comment thread src/loadEnvVars.ts Outdated
Comment thread __tests__/index.test.ts
noahtigner and others added 4 commits November 25, 2025 18:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Noah Tigner <46695778+noahtigner@users.noreply.github.com>
@noahtigner
noahtigner merged commit 46a14eb into main Dec 2, 2025
4 checks passed
@noahtigner
noahtigner deleted the feature/v2 branch December 2, 2025 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants