Built-in Schemas
Reference for string, number, URL, boolean, and parsed environment schemas.
All built-in schemas are Effect Schemas and may be used directly in a server or client fragment:
const appEnv = createEnv(
server({
PORT: port,
DATABASE_URL: redacted(postgresUrl),
}),
);
Strings
| Name | Type | Default | Description |
|---|---|---|---|
| requiredString | string | — | A present, non-empty string. |
Use optional(schema) when absence is valid.
Numbers
| Name | Type | Default | Description |
|---|---|---|---|
| number | number | — | Any number parsed from a string. |
| positiveNumber | number | — | A number greater than zero. |
| integer | number | — | A whole number. |
| nonNegativeNumber | number | — | A number greater than or equal to zero. |
| port | number | — | A whole number from 1 through 65535. |
values: {
PORT: port,
MAX_RETRIES: integer,
RATE_LIMIT: positiveNumber,
THRESHOLD: number,
}
Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| boolean | boolean | — | Parses true, false, 1, or 0 without case sensitivity. |
values: {
DEBUG: boolean,
}
URLs
| Name | Type | Default | Description |
|---|---|---|---|
| url | string | — | HTTP or HTTPS URL. |
| postgresUrl | string | — | PostgreSQL connection URL. |
| redisUrl | string | — | Redis connection URL. |
| mongoUrl | string | — | MongoDB connection URL. |
| mysqlUrl | string | — | MySQL connection URL. |
| commaSeparatedUrls | string[] | — | Comma-separated HTTP and HTTPS URLs. |
Server connection URLs should normally be redacted:
values: {
DATABASE_URL: redacted(postgresUrl),
REDIS_URL: redacted(redisUrl),
WEBHOOK_URL: url,
}
Comma-separated values
| Name | Type | Default | Description |
|---|---|---|---|
| commaSeparated | string[] | — | Trimmed strings separated by commas. |
| commaSeparatedNumbers | number[] | — | Numbers separated by commas. |
values: {
ALLOWED_ORIGINS: commaSeparated,
RETRY_DELAYS: commaSeparatedNumbers,
}
Parameterized schemas
stringEnum
values: {
LOG_LEVEL: stringEnum(["debug", "info", "warn", "error"]),
}
json
import { Schema } from "effect";
values: {
JSON_CONFIG: json(
Schema.Struct({
retries: Schema.Number,
timeout: Schema.Number,
}),
),
}
Effect Schema
Effect Schemas with context requirements are accepted. Schema outputs must not be functions:
values: {
NODE_ENV: Schema.Literal("development", "production", "test"),
API_KEY: Schema.String.check(Schema.isMinLength(32)),
}
Tip
Use Effect Schema directly when the built-in set does not express the desired validation and decoded type. Its errors and context requirements are preserved by the resulting environment Effect.