has_contract_enforced

has_contract_enforced

Rule: has_contract_enforced

Manifest Rule

has_contract_enforced details
This rule ensures that models have contracts enforced. Model contracts in dbt allow you to define explicit expectations for your data models, such as schema, data types, and constraints. See the [dbt model contracts documentation](https://docs.getdbt.com/docs/mesh/govern/model-contracts) for more details.

Configuration

  • type: Must be has_contract_enforced.
  • access_level: (optional) Only check models with this access level. When not set, all models are checked.
    • Options: public, protected, private
  • applies_to: (optional) List of dbt object types to check.
    • Default: ["models"]
    • Options: models
Common Rule Config
  • name: Human-readable name of the rule.
  • severity: "error" (fail) or "warning" (warn only).
    • (optional, defaults to "error" if not specified)
  • description: Human-readable explanation of the rule.
  • category: Override the default rule category. Included in structured output (JSON, CSV, NDJSON) but not in the CLI table. Each rule has a built-in default (e.g. documentation, naming, testing, governance, structure, performance).
    • (optional, defaults to the rule type's built-in category)
  • includes: List of patterns to explicitly include for this rule. See Includes & Excludes for pattern syntax and examples.
  • excludes: List of patterns to explicitly exclude from this rule. See Includes & Excludes for pattern syntax and examples.
  • model_materializations: Filter models by materialization type. Only applies when applies_to includes models.
    • (optional, if not specified all materializations are included)
    • Built-in types: table, view, incremental, ephemeral, materialized_view. Custom materializations are also supported.
    • Example: ["table", "incremental"]

Example Config

manifest_tests:
  # Enforce contracts on all models
  - name: "enforce_model_contracts"
    type: "has_contract_enforced"
    description: "All models must have contracts enforced."

  # Only enforce contracts on public models
  - name: "public_models_have_contracts"
    type: "has_contract_enforced"
    access_level: "public"
    description: "Public models must have contracts enforced."
# Enforce contracts on all models
[[manifest_tests]]
name = "enforce_model_contracts"
type = "has_contract_enforced"
description = "All models must have contracts enforced."

# Only enforce contracts on public models
[[manifest_tests]]
name = "public_models_have_contracts"
type = "has_contract_enforced"
access_level = "public"
description = "Public models must have contracts enforced."
# Enforce contracts on all models
[[tool.dbtective.manifest_tests]]
name = "enforce_model_contracts"
type = "has_contract_enforced"
description = "All models must have contracts enforced."

# Only enforce contracts on public models
[[tool.dbtective.manifest_tests]]
name = "public_models_have_contracts"
type = "has_contract_enforced"
access_level = "public"
description = "Public models must have contracts enforced."
Relevant dbt code
models:
  your_model_name:
    config:
        contract:
            enforced: true