-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Problem Description:
Currently, ArkEnv reads all environment variables as strings by default. This causes issues when dealing with boolean values, as they are also interpreted as strings.
For example, a boolean environment variable like ENABLE_FEATURE=true is read as the string "true" instead of the boolean value true.
Use Case:
In cases where environment variables are used to configure features or toggles, boolean values are essential. We need a way to reliably convert these string values into actual boolean types within ArkEnv.
Proposed Solution:
Introduce a mechanism to automatically convert string values to boolean types when appropriate. This could involve:
Explicit Type Definition: Allow users to specify the expected type of an environment variable (e.g., boolean).
Automatic Type Inference: If possible, automatically detect and convert string values that represent boolean values ("true", "false", "1", "0", etc.).
Custom Conversion Functions: Provide a way to define custom conversion functions for specific environment variables.
Example:
For non-optional attributes with default values, the following code snippet demonstrates a workaround:
type("string").pipe((str) => Boolean(str).valueOf());However, this approach doesn't address the scenario where the boolean value is a key within an object.
Additional Considerations:
How to handle cases where the string value cannot be converted to a boolean (e.g., "invalid")?
Should this conversion be optional or enabled by default?
Request:
Please consider implementing a solution to support boolean type conversion for ArkEnv, providing a more robust and flexible way to handle environment variable configuration.
Thank you.