Skip to Content
Env ValidationTypes & Reference

Types & VarConfig Reference

Shorthand

"KEY": "type" validates the type only; the variable is required by default.

{ "env": [ { "label": "web", "path": "apps/web/.env.local", "variables": { "PORT": "port", "DATABASE_URL": "url", "API_KEY": "string" } } ] }

Shorthand-supported types: string, port, int, int+, float, bool, url, email, json, uuid. The pattern and enum types cannot use shorthand because they require additional fields (pattern or values).

VarConfig

For full control, use an object with a type and optional fields:

FieldRequiredDefaultNotes
typeyesOne of: string, port, int, int+, float, bool, url, enum, email, json, uuid, pattern
optionalnofalseIf true, missing value passes validation
minnotype-specificstring: length (default 1). int/int+/float: value range
maxnotype-specificstring: length (default 255). int/int+/float: value range
patternnoRegex for pattern type
valuesnoAllowed values for enum type
schemesno["http","https"]URL schemes for url type
trueValuesno["true","1","yes","on"]Bool parsing
falseValuesno["false","0","no","off"]Bool parsing

Unknown VarConfig keys cause an error (strict mode).

Types

TypeDescription
stringNon-empty string. min/max = length (chars).
portInteger 1–65535.
intAny integer.
int+Positive integer. min defaults to 1.
floatFloat.
boolBoolean. Uses trueValues/falseValues for parsing.
urlURL. schemes restricts allowed schemes (default http/https).
enumOne of values. Requires values array.
emailEmail address.
jsonValid JSON.
uuidUUID.
patternRegex match. Requires pattern field.

Examples

Optional variable with enum:

"NODE_ENV": { "type": "enum", "values": ["development", "production", "test"], "optional": true }

String with length constraints:

"APP_NAME": { "type": "string", "min": 1, "max": 50 }

Custom regex:

"VERSION": { "type": "pattern", "pattern": "^v?\\d+\\.\\d+\\.\\d+$" }

Full multi-app example:

{ "env": [ { "label": "web", "path": "apps/web/.env.local", "variables": { "PORT": "port", "DATABASE_URL": "url", "API_KEY": { "type": "string", "min": 1, "max": 32 }, "DEBUG_MODE": "bool" } }, { "label": "api", "path": "apps/api/.env", "required": "all", "variables": { "NODE_ENV": { "type": "enum", "values": ["development", "production", "test"], "optional": true }, "REDIS_URL": { "type": "url", "schemes": ["redis", "rediss"] }, "RATE_LIMIT": { "type": "int+", "min": 1, "max": 1000 } } } ] }
Last updated on