fatima

Models and validation

Define expected variable shapes and validate them before use.

The model object declares expected variables and their types. It is used by fatima validate, by strict generation, and by generated SDK files.

Model syntax

Use a string for a simple model:

{
  "model": {
    "DATABASE_URL": "url",
    "PORT": "integer"
  }
}

Use an object when the model needs arguments:

{
  "model": {
    "NODE_ENV": {
      "type": "string",
      "args": { "values": ["development", "production"] }
    }
  }
}

The values argument restricts the parsed value to one of the listed values.

Built-in models

ModelAccepted value
stringAny present string.
nonemptyA string with non-whitespace content.
emailA basic email-like value.
urlA value with http:// or https://.
uuidA five-part hexadecimal UUID.
numberA value parseable as a number.
integerA numeric value without a fractional part.
booleantrue, 1, yes, on, y, enabled, false, 0, no, off, n, or disabled.
jsonValid JSON text.
pemA value containing PEM begin and end markers.
skA value starting with sk- or sk_.
bearerA value starting with Bearer .

Validation behavior

fatima validate requires a non-empty model. It loads the selected environment, then validates every key declared in the model. Extra loaded variables are allowed.

fatima validate --environment production

Generation can also validate first:

fatima generate --strict

Use strict generation in CI when generated files must never be produced from invalid configuration.