Skip to main content

Schema Reference

The schema is a Record<string, SchemaRule> where SchemaRule includes the following fields:

  • type — one of string, number, boolean, date, object, array, email, url, ip, json, port
  • required — boolean
  • default — any
  • min, max, minLength, maxLength
  • validate(value) => boolean custom validator
  • transform(value) => any value transform
  • sensitive — boolean; when true this value is masked in errors and excluded from .env.example
  • encrypted — boolean; when true the value must be stored as an encrypted:v1:… token (see Encryption)
  • docs — string documentation
  • enum — array of allowed values
  • regex / regexError
  • itemsSchemaRule for array items
  • propertiesRecord<string, SchemaRule> for object types
  • envPrefix — optional string used to map grouped envs into object properties (defaults to <KEY>_ when properties exists)

Example:

{
DATABASE: {
type: 'object',
properties: {
HOST: { type: 'string' },
PORT: { type: 'port', default: 5432 }
}
}
}