Ciaren

Assert values in set

Assert values in set — assertValuesInSet

Fail or warn when a column contains values outside an allowed set — a domain check for categorical columns. Like the other data-quality nodes, the output frame is the input passed through unchanged.

Use cases

  • Guarantee status is only paid, pending, or failed.
  • Catch typos or unexpected categories before they reach a report.
  • Enforce a controlled vocabulary as a data contract.

What it does

Each value in the column is checked against the allowed set. Violations either fail the run (mode: error, the default) or are recorded as a warning (mode: warn) so the run continues. Nulls are tolerated by default.

Configuration

Config keyTypeRequiredDescription
columnstringYesThe column to check
allowedstring[]YesThe permitted values (≥ 1)
allow_nullbooleanNoTreat null as allowed (default true)
modestringNoerror (default) or warn

Generated Python code

df_2 = df_1
_set_mask = df_2["status"].isin(["paid", "pending", "failed"]) | df_2["status"].isna()
if not _set_mask.all():
    raise ValueError(f"assertValuesInSet: {(~_set_mask).sum()} row(s) in 'status' outside the allowed set")

Tips & common mistakes

See also