expect_column_value_lengths_to_equal

Feb 23, 2026dbt-expectations · Column · Values format

How it Works

The expect_column_value_lengths_to_equal test from the dbt-expectations package verifies that every value in a column has exactly a specified character length. This is ideal for fixed-format identifiers like national ID numbers, ISO country codes, or product SKUs that always require a precise length.

Steps and Conditions

  1. Column Selection: Identify the column to evaluate.
  2. Set Expected Length: Provide the required character length using value.
  3. Optional Row Condition: Filter rows with row_condition if needed.
  4. Execution: The length of each value is measured and compared to the expected value.
  5. Outcome: Pass if all values have the correct length; fail if any deviate.

Example Usage: Banking

A banking platform stores IBAN codes that are always 22 characters for a specific country. The team wants to enforce this constraint at the data layer.

models:
  - name: bank_accounts
    columns:
      - name: iban_code
        tests:
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 22

Any IBAN code that is shorter or longer than 22 characters will fail the test, alerting the team to a data entry or ingestion error.

Interested to Learn More? Try Out the Free 14-Days Trial

One AI-native workspace to build, ship, and monitor dbt™ — without the tool sprawl.

Join industry leaders winning with DinoAI agents

Data engineers and analysts at the most AI-native startups and enterprises use Paradime's DinoAI agents everyday to become market leaders.