Validation with Final Actions

Execute actions after validation completes, such as sending alerts or generating summary reports.

Validation workflow completed.
🚨 ALERT: Critical validation failures found!
   Failed steps: 2

--- Validation Summary Report ---
Total validation steps: 3
Passed steps: 1
Failed steps: 2
Highest severity: critical
--- End of Report ---
Pointblank Validation
Validation with final actions
PolarsWARNING0.05ERROR0.1CRITICAL0.15
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_regex
col_vals_regex()
player_id [A-Z]{12}[0-9]{3} 2000 2000
1.00
0
0.00
#EBBC14 2
col_vals_gt
col_vals_gt()
item_revenue 0.05 2000 1701
0.85
299
0.15
#FF3300 3
col_vals_gt
col_vals_gt()
session_duration 15 2000 1675
0.84
325
0.16
2025-06-22 01:26:34 UTC< 1 s2025-06-22 01:26:34 UTC
import pointblank as pb

def send_alert():
    """Check validation summary and send alert if critical failures found"""
    summary = pb.get_validation_summary()
    if summary and summary.get("highest_severity") == "critical":
        print(f"🚨 ALERT: Critical validation failures found!")
        print(f"   Failed steps: {summary['n_failing_steps']}")
    elif summary and summary.get("highest_severity") == "error":
        print(f"⚠️  WARNING: Error-level validation failures detected.")
    else:
        print("✅ All validation checks passed successfully!")

def generate_summary_report():
    """Generate a summary report of validation results"""
    summary = pb.get_validation_summary()
    if summary:
        print("\n--- Validation Summary Report ---")
        print(f"Total validation steps: {summary['n_steps']}")
        print(f"Passed steps: {summary['n_passing_steps']}")
        print(f"Failed steps: {summary['n_failing_steps']}")
        print(f"Highest severity: {summary['highest_severity']}")
        print("--- End of Report ---")

validation = (
    pb.Validate(
        data=pb.load_dataset(dataset="game_revenue", tbl_type="polars"),
        label="Validation with final actions",
        thresholds=pb.Thresholds(warning=0.05, error=0.10, critical=0.15),
        final_actions=pb.FinalActions(
            "Validation workflow completed.",  # String message
            send_alert,                        # Alert function
            generate_summary_report            # Report function
        )
    )
    .col_vals_regex(columns="player_id", pattern=r"[A-Z]{12}[0-9]{3}")
    .col_vals_gt(columns="item_revenue", value=0.05)
    .col_vals_gt(columns="session_duration", value=15)
    .interrogate()
)

validation
Preview of Input Table
PolarsRows2,000Columns11
player_id
String
session_id
String
session_start
Datetime
time
Datetime
item_type
String
item_name
String
item_revenue
Float64
session_duration
Float64
start_day
Date
acquisition
String
country
String
1 ECPANOIXLZHF896 ECPANOIXLZHF896-eol2j8bs 2015-01-01 01:31:03+00:00 2015-01-01 01:31:27+00:00 iap offer2 8.99 16.3 2015-01-01 google Germany
2 ECPANOIXLZHF896 ECPANOIXLZHF896-eol2j8bs 2015-01-01 01:31:03+00:00 2015-01-01 01:36:57+00:00 iap gems3 22.49 16.3 2015-01-01 google Germany
3 ECPANOIXLZHF896 ECPANOIXLZHF896-eol2j8bs 2015-01-01 01:31:03+00:00 2015-01-01 01:37:45+00:00 iap gold7 107.99 16.3 2015-01-01 google Germany
4 ECPANOIXLZHF896 ECPANOIXLZHF896-eol2j8bs 2015-01-01 01:31:03+00:00 2015-01-01 01:42:33+00:00 ad ad_20sec 0.76 16.3 2015-01-01 google Germany
5 ECPANOIXLZHF896 ECPANOIXLZHF896-hdu9jkls 2015-01-01 11:50:02+00:00 2015-01-01 11:55:20+00:00 ad ad_5sec 0.03 35.2 2015-01-01 google Germany
1996 NAOJRDMCSEBI281 NAOJRDMCSEBI281-j2vs9ilp 2015-01-21 01:57:50+00:00 2015-01-21 02:02:50+00:00 ad ad_survey 1.332 25.8 2015-01-11 organic Norway
1997 NAOJRDMCSEBI281 NAOJRDMCSEBI281-j2vs9ilp 2015-01-21 01:57:50+00:00 2015-01-21 02:22:14+00:00 ad ad_survey 1.35 25.8 2015-01-11 organic Norway
1998 RMOSWHJGELCI675 RMOSWHJGELCI675-vbhcsmtr 2015-01-21 02:39:48+00:00 2015-01-21 02:40:00+00:00 ad ad_5sec 0.03 8.4 2015-01-10 other_campaign France
1999 RMOSWHJGELCI675 RMOSWHJGELCI675-vbhcsmtr 2015-01-21 02:39:48+00:00 2015-01-21 02:47:12+00:00 iap offer5 26.09 8.4 2015-01-10 other_campaign France
2000 GJCXNTWEBIPQ369 GJCXNTWEBIPQ369-9elq67md 2015-01-21 03:59:23+00:00 2015-01-21 04:06:29+00:00 ad ad_5sec 0.12 18.5 2015-01-14 organic United States