Repository navigation
node-env-resolver-nextjs@7.1.0
·
36 commits
to main
since this release
Minor Changes
-
e71a403: Add support for optional enum arrays with new
enumOf()function andoptional()wrapper.New Features:
enumOf()function: A clearer, more explicit alternative tooneOf()specifically designed for enum validation. Supports optional values and default values.optional()wrapper: Enables clean array literal syntax for optional enums. Simply wrap your enum array withoptional()to make it optional.
Usage Examples:
import { resolve } from 'node-env-resolver'; import { optional, enumOf } from 'node-env-resolver/validators'; const config = resolve({ // Required enum (existing syntax still works) NODE_ENV: ['development', 'production', 'test'] as const, // Optional enum - Method 1: optional() wrapper (clean syntax) PROTOCOL: optional(['http', 'grpc'] as const), // Optional enum - Method 2: enumOf() function (explicit) LOG_LEVEL: enumOf(['error', 'warn', 'info', 'debug'] as const, { optional: true }), // Enum with default value COMPRESSION: enumOf(['gzip', 'brotli', 'none'] as const, { default: 'gzip' }), }); // TypeScript infers correct types: // config.NODE_ENV: 'development' | 'production' | 'test' // config.PROTOCOL: 'http' | 'grpc' | undefined // config.LOG_LEVEL: 'error' | 'warn' | 'info' | 'debug' | undefined // config.COMPRESSION: 'gzip' | 'brotli' | 'none'
Backward Compatibility:
- All existing code continues to work unchanged
oneOf()remains available as an alias forenumOf()for backward compatibility- Plain array syntax
['a', 'b'] as conststill works for required enums
Patch Changes
- Updated dependencies [e71a403]
- node-env-resolver@6.1.0