expect_column_value_lengths_to_be_between
Feb 24, 2026
·
5
min read
Values format
·
dbt-expectations
·
Column
How it Works
The expect_column_value_lengths_to_be_between test from the dbt-expectations package validates that the character length of every value in a string column falls within a defined minimum and maximum range. This is useful for variable-length fields that nonetheless have sensible bounds — for example, user names, addresses, or short text fields.
An optional row_condition can scope the check.
Steps and Conditions
Column Selection: Identify the string column to evaluate.
Define Length Range: Set
min_valueand/ormax_value.Optional Row Condition: Filter rows using
row_condition.Execution: The length of each value is measured and compared to the range.
Outcome: Pass if all lengths are within range; fail if any fall outside.
Example Usage: User Registration
A user registration system requires that usernames be between 3 and 30 characters long.
This catches usernames that are too short (likely a data entry error) or too long (possibly truncated by a frontend that didn't enforce the constraint).





