Level Up Your Data Validation with Actions and FinalActions
Author
Rich Iannone
Published
May 2, 2025
Data validation is only useful if you can respond appropriately when problems arise. That’s why Pointblank’s recent v0.8.0 and v0.8.1 releases have significantly enhanced our action framework, allowing you to create sophisticated, automated responses to validation failures.
In this post, we’ll explore how to use:
Actions to respond to individual validation failures
FinalActions to execute code after your entire validation plan completes
New customization features that make your validation workflows more expressive
Let’s dive into how these features can transform your data validation process from passive reporting to active response.
From Passive Validation to Active Response
Traditional data validation simply reports problems: “Column X has invalid values.” But what if you want to:
send a Slack message when critical errors occur?
log detailed diagnostics about failing data?
trigger automatic data cleaning processes?
generate custom reports for stakeholders?
This is where Pointblank’s action system can help. By pairing thresholds with actions, you can create automated responses that trigger exactly when needed.
Getting Started with Actions
Actions are executed when validation steps fail to meet certain thresholds. Let’s start with a simple example:
import pointblank as pbvalidation_1 = ( pb.Validate(data=pb.load_dataset(dataset="small_table")) .col_vals_gt( columns="d", value=1000, thresholds=pb.Thresholds(warning=1, error=5), actions=pb.Actions( warning="⚠️ WARNING: Some values in column 'd' are below the minimum threshold!" ) ) .interrogate())validation_1
⚠️ WARNING: Some values in column 'd' are below the minimum threshold!
Pointblank Validation
2025-05-06|14:30:37
Polars
STEP
COLUMNS
VALUES
TBL
EVAL
UNITS
PASS
FAIL
W
E
C
EXT
#EBBC14
1
col_vals_gt()
d
1000
✓
13
7 0.54
6 0.46
●
●
—
In this example:
we’re validating that values in column “d” are greater than 1000
we set a warning threshold of 1 (triggers if any values fail)
we define an action that prints a warning message when the threshold is exceeded
Since several values in column d are below 1000, our ‘warning’ action is triggered and the message appears above the validation report.
The Anatomy of Actions
The Actions class is a very important piece of Pointblank’s response system. Actions can be defined in several ways:
String messages: simple text output to the console
Callable functions: custom Python functions that execute when triggered
Lists of strings/callables: multiple actions that execute in sequence
Actions can be paired with different severity levels:
‘warning’: for minor issues that need attention
‘error’: for more significant problems
‘critical’: for severe issues that require immediate action
The v0.8.0 release added two (very) useful new parameters:
default=: apply the same action to all threshold levels
highest_only=: only trigger the action for the highest threshold level reached (True by default)
Let’s see how these work in practice:
def log_problem():# Simple action that runs when thresholds are exceededprint("A validation threshold has been exceeded!")validation_2 = ( pb.Validate( data=pb.load_dataset(dataset="game_revenue"), thresholds=pb.Thresholds(warning=0.05, error=0.10, critical=0.15), actions=pb.Actions(default=log_problem) # Apply this action to all threshold levels ) .col_vals_regex( columns="player_id", pattern=r"[A-Z]{12}\d{3}" ) .col_vals_gt( columns="item_revenue", value=0.10 ) .interrogate())validation_2
A validation threshold has been exceeded!
Pointblank Validation
2025-05-06|14:30:37
PolarsWARNING0.05ERROR0.1CRITICAL0.15
STEP
COLUMNS
VALUES
TBL
EVAL
UNITS
PASS
FAIL
W
E
C
EXT
#4CA64C
1
col_vals_regex()
player_id
[A-Z]{12}\d{3}
✓
2000
2000 1.00
0 0.00
○
○
○
—
#FF3300
2
col_vals_gt()
item_revenue
0.1
✓
2000
1440 0.72
560 0.28
●
●
●
In this example, we’re using a simple function that prints a generic message whenever any threshold is exceeded. By using the Actions(default=) parameter, this same function gets applied to all threshold levels (‘warning’, ‘error’, and ‘critical’). This saves you from having to define separate actions for each level when you want the same behavior for all of them. The highest_only= parameter (True by default, so not shown here) is complementary and it ensures that only the action for the highest threshold level reached will be triggered, preventing multiple notifications for the same validation failure.
Dynamic Messages with Templating
Actions don’t have to be static messages. With Pointblank’s templating system, you can create context-aware notifications that include details about the specific validation failure.
Available placeholders include:
{type}: the validation step type (e.g., "col_vals_gt")
{level}: the threshold level (‘warning’, ‘error’, ‘critical’)
{step} or {i}: the step number in the validation workflow
{col} or {column}: the column name being validated
{val} or {value}: the comparison value used in the validation
{time}: when the action was executed
You can also capitalize placeholders (like {LEVEL}) to get uppercase text.
[ERROR] Step 1: Values in 'd' failed validation against 3000.
Pointblank Validation
2025-05-06|14:30:37
PolarsWARNING1ERROR4CRITICAL10
STEP
COLUMNS
VALUES
TBL
EVAL
UNITS
PASS
FAIL
W
E
C
EXT
#EBBC14
1
col_vals_lt()
d
3000
✓
13
9 0.69
4 0.31
●
●
○
This templating approach is a great way to create context-aware notifications that adapt to the specific validation failures occurring. As the example shows, when values in column d fail validation against the limit of 3000, the template automatically generates a meaningful error message showing exactly which step, column, and threshold value was involved.
Accessing Metadata in Custom Action Functions
For more sophisticated actions, you often need access to details about the validation failure. The get_action_metadata() function provides this context when called inside an action function:
VALIDATION FAILURE DETAILS
-------------------------
Step: 1
Column: d
Validation type: col_vals_gt
Severity: critical (level 50)
Time: 2025-05-06 14:30:37.821585+00:00
Explanation: Exceedance of failed test units where values in `d` should have been > `5000`.
Pointblank Validation
2025-05-06|14:30:37
PolarsWARNING—ERROR—CRITICAL1
STEP
COLUMNS
VALUES
TBL
EVAL
UNITS
PASS
FAIL
W
E
C
EXT
#FF3300
1
col_vals_gt()
d
5000
✓
13
1 0.08
12 0.92
—
—
●
The metadata dictionary contains essential fields for a given validation step, including the step number, column name, validation type, severity level, and failure explanation. This gives you complete flexibility to create highly customized responses based on the specific nature of the validation failure.
Final Actions with FinalActions
While regular Actions are great for responding to individual validation steps, sometimes you need to take action based on the overall validation results. This is where the new FinalActions feature from v0.8.1 comes in.
Unlike regular Actions that trigger during validation, FinalActions execute after all validation steps are complete. FinalActions accepts any number of actions (strings or callables) and executes them in sequence. Each argument can be a string message to display in the console, a callable function, or a list of strings/callables for multiple actions to execute in sequence.
The real power of FinalActions comes from the ability to access comprehensive information about your validation results using get_validation_summary(). When called inside a function passed to FinalActions, this function provides a dictionary containing counts of passing/failing steps and test units, threshold levels exceeded, and much more:
This approach allows you to log individual step failures during the validation process using Actions and generate a comprehensive report after all validation steps are complete using FinalActions. Using both action types gives you fine-grained control over when and how notifications and other actions are triggered in your validation workflow.
Real-World Example: Building an Automated Validation Pipeline
Let’s put everything together in a more realistic example. Imagine you’re validating a gaming revenue dataset and want to:
log detailed information about each failure
send a Slack notification if critical failures occur
generate a comprehensive report after validation completes
def log_step_failure(): metadata = pb.get_action_metadata()print(f"[{metadata['level'].upper()}] Step {metadata['step']}: {metadata['failure_text']}")def analyze_results(): summary = pb.get_validation_summary()# Calculate overall pass rate pass_rate = (summary['n_passing_steps'] / summary['n_steps']) *100print(f"\n==== VALIDATION RESULTS ====")print(f"Table: {summary['tbl_name']}")print(f"Pass rate: {pass_rate:.2f}%")print(f"Failing steps: {summary['n_failing_steps']} of {summary['n_steps']}")# In a real scenario, here you might:# 1. Save results to a database# 2. Generate and email an HTML report# 3. Trigger data cleansing workflows# Simulate a Slack notificationif summary['highest_severity'] =="critical":print("\n🚨 [SLACK NOTIFICATION] Critical data quality issues detected!")print("@data-team Please investigate immediately.")# Create our validation workflow with actionsvalidation_7 = ( pb.Validate( data=pb.load_dataset(dataset="game_revenue"), tbl_name="game_revenue", thresholds=pb.Thresholds(warning=0.05, error=0.10, critical=0.15), actions=pb.Actions(default=log_step_failure, highest_only=True), final_actions=pb.FinalActions(analyze_results), brief=True# Add automatically-generated briefs ) .col_vals_regex( columns="player_id", pattern=r"[A-Z]{12}\d{3}", brief="Player IDs must follow standard format"# Custom brief text ) .col_vals_gt( columns="item_revenue", value=0.10 ) .col_vals_gt( columns="session_duration", value=15 ) .interrogate())validation_7
[CRITICAL] Step 2: Exceedance of failed test units where values in `item_revenue` should have been > `0.1`.
[CRITICAL] Step 3: Exceedance of failed test units where values in `session_duration` should have been > `15`.
==== VALIDATION RESULTS ====
Table: game_revenue
Pass rate: 33.33%
Failing steps: 2 of 3
🚨 [SLACK NOTIFICATION] Critical data quality issues detected!
@data-team Please investigate immediately.
Pointblank Validation
2025-05-06|14:30:38
Polarsgame_revenueWARNING0.05ERROR0.1CRITICAL0.15
STEP
COLUMNS
VALUES
TBL
EVAL
UNITS
PASS
FAIL
W
E
C
EXT
#4CA64C
1
col_vals_regex()
Player IDs must follow standard format
player_id
[A-Z]{12}\d{3}
✓
2000
2000 1.00
0 0.00
○
○
○
—
#FF3300
2
col_vals_gt()
Expect that values in item_revenue should be > 0.1.
item_revenue
0.1
✓
2000
1440 0.72
560 0.28
●
●
●
#FF3300
3
col_vals_gt()
Expect that values in session_duration should be > 15.
session_duration
15
✓
2000
1675 0.84
325 0.16
●
●
●
Wrapping Up: from Passive Validation to Active Data Quality Management
With Actions and FinalActions, Pointblank is now more of a complete data quality management system. Instead of just detecting problems, you can now:
respond immediately to validation failures
customize responses based on severity level
generate comprehensive reports after validation completes
integrate with other systems through custom action functions
automate workflows based on validation results
These capabilities transform data validation from a passive reporting activity into an active component of your data pipeline, helping ensure that data quality issues are detected, reported, and addressed efficiently.
As we continue to enhance Pointblank, we’d love to hear how you’re using Actions and FinalActions in your workflows. Share your experiences or suggestions with us on Discord or file an issue on GitHub.
Learn More
Explore our documentation to learn more about Pointblank’s action capabilities: