You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// make the type of the environment variables available globally
@@ -136,15 +127,40 @@ interface ImportMeta {
136
127
137
128
4. Add your schema configuration file to your tsconfig's `include`
138
129
139
-
# Tips:
140
-
141
-
- If you don't have a `.env` file, you can pass an empty file. This is useful for testing and CI/CD environments, where environment variables may be set programmatically.
| `schema` | `EnvObject` | The schema to validate against | |
148
-
| `envPath` (optional) | `string` | The path to the .env file | `.env` |
134
+
| `schema` | `EnvObject` | The schema to validate against (must use string-based types) | |
135
+
| `envPath` (optional) | `string` | The path to the .env file | |
149
136
| `exitOnError` (optional) | `boolean` | Whether to exit the process or throw if validation fails | `false` |
150
137
| `logVars` (optional) | `boolean` | Whether to output successfully parsed variables to the console | `true` |
138
+
139
+
**Note:** The `schema` must be a `z.object()` whose fields use string-based types—such as `z.string()`, `z.enum()`, `z.literal()`, or compositions like union/optional of these types. You may also use any Zod string refinements and formats (e.g., `.min()`, `.max()`, `.url()`, `.email()`, `.regex()`, `.refine()`, etc.) to validate and transform string values. Environment variables are always read as strings.
140
+
141
+
# Schema Recipes
142
+
143
+
Since environment variables are always read as strings, you'll need to validate and transform them appropriately. Here are some common patterns:
0 commit comments