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. - applies_to: (optional) List of dbt object types to check.
- Default:
["models"] - Options:
models
- Default:
Common Rule Config
- name: Human-readable name of the rule.
- severity:
"error"(fail) or"warning"(warn only).- (optional, defaults to
"error"if not specified)
- (optional, defaults to
- description: Human-readable explanation of the rule.
- includes: List of patterns to explicitly include for this rule.
Paths are relative to theoriginal_file_pathfrom the manifest.
Pattern syntax:*matches any characters except/(within a single directory)**matches any characters including/(across directories)^at the start anchors to the beginning of the path$at the end anchors to the end of the path- Without anchors, pattern matches if it appears anywhere in the path (contains)
Examples:^models/staging/- paths starting withmodels/staging/orders- paths containingordersanywhere.sql$- paths ending with.sql^models/*.sql$- SQL files directly inmodels/folder^models/**/*.sql$- SQL files in any subfolder ofmodels/
- excludes: List of patterns to explicitly exclude from this rule.
Uses the same pattern syntax asincludes.
Examples:^models/legacy/- exclude legacy models folder_deprecated- exclude paths containing_deprecated^tests/- exclude test files - model_materializations: Filter models by materialization type. Only applies when
applies_toincludesmodels.
(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:
- name: "enforce_model_contracts"
type: "has_contract_enforced"
description: "All models must have contracts enforced."[[manifest_tests]]
name = "enforce_model_contracts"
type = "has_contract_enforced"
description = "All models must have contracts enforced."[[tool.dbtective.manifest_tests]]
name = "enforce_model_contracts"
type = "has_contract_enforced"
description = "All models must have contracts enforced."Relevant dbt code
models:
your_model_name:
config:
contract:
enforced: true