Skip to content

Schema Format Reference

Complete reference for the envguard.yaml schema file format.

Top-Level Fields

yaml
version: "1.0"           # Required. Schema version.
extends: "base.yaml"     # Optional. Inherit from another schema.
env:                     # Required. Variable definitions.
  # ...
secrets:                 # Optional. Custom secret rules.
  custom:
    # ...

Variable Definition

yaml
VARIABLE_NAME:
  type: string           # Required
  required: true
  default: "fallback"
  description: "Human-readable docs"
  message: "Custom error message"
  pattern: "^regex$"
  enum: [a, b, c]
  min: 1
  max: 100
  minLength: 1
  maxLength: 255
  format: email
  disallow: [forbidden1, forbidden2]
  requiredIn: [production, staging]
  devOnly: false
  separator: ","
  allowEmpty: true
  contains: "required-item"
  dependsOn: OTHER_VAR
  when: "specific-value"
  deprecated: "Use NEW_VAR instead"
  sensitive: true
  transform: lowercase

Types

TypeDescriptionExample Values
stringAny texthello, https://example.com
integerWhole numbers42, -1, 0
floatDecimal numbers3.14, -2.5, 1.5e10
booleanTrue/falsetrue, false, 1, 0, yes, no, on, off
arrayComma-separated valuesa,b,c

Formats

FormatRegex/ValidationExample
emailRFC 5322user@example.com
urlStandard URLhttps://api.example.com/v1
uuidUUID v4550e8400-e29b-41d4-a716-446655440000
base64Base64 alphabetSGVsbG8gV29ybGQ=
ipIPv4 or IPv6192.168.1.1, ::1
port1-655358080
jsonValid JSON{"key": "value"}
durationGo duration5m30s, 1h
semverSemantic version1.2.3, 2.0.0-beta.1
hostnameRFC 1123api.example.com
hexHexadecimala1b2c3d4
cronCron expression0 0 * * *

Constraints

  • required: true and default are mutually exclusive in practice
  • enum values must be compatible with the variable's type
  • pattern is only applied to string types
  • Empty enums (enum: []) are rejected as invalid schema definitions
  • Whitespace-only values fail required checks
  • devOnly: true and required / requiredIn are mutually exclusive
  • dependsOn and when must be used together
  • allowEmpty: false is redundant when required: true
  • min cannot be greater than max
  • minLength cannot be greater than maxLength
  • array type requires a separator
  • transform can only be used with string type
  • Circular extends inheritance is detected and rejected

Custom Secret Rules

yaml
secrets:
  custom:
    - name: "internal-api-token"
      pattern: "iat_[a-zA-Z0-9]{32}"
      message: "Internal API token detected"
      severity: "high"
FieldRequiredDescription
nameYesRule identifier
patternYesRegex pattern
messageYesHuman-readable message
severityNocritical, high, medium, low

Released under the MIT License.