Skip to main content

Assertion Node

The assertion node allows you to validate data flowing through your ZephFlow pipeline against specified conditions. It evaluates each incoming event against an expression written in the Fleak Eval Expression Language (FEEL). Unlike the filter node which drops non-matching events, the assertion node produces error outputs for events that fail validation, allowing you to handle invalid data explicitly.

For more details of using FEEL, please refer to FEEL Reference

Key Features

  • Data Validation: Enforce data quality constraints within your pipeline
  • Error Handling: Generate explicit error events that can be routed to Dead Letter Queues (DLQ)
  • Schema Enforcement: Ensure events conform to expected structures and value constraints
  • Custom Validation Logic: Apply complex validation rules with the full power of FEEL

Attaching Assertion Node Using SDK

ZephFlow flow = ZephFlow.startFlow();
flow.assertion("your FEEL assertion");

Basic Usage

The assertion node evaluates an expression for each event:

  • If the expression evaluates to true, the event passes validation and continues through the pipeline
  • If the expression evaluates to anything other than true, an error is generated and the event is routed to error handling (DLQ if configured)
# Assert that the status field equals "success" or "pending"
$.status == "success" or $.status == "pending"

# Assert that response time is under 500ms
$.response_time < 500

# Assert that required fields are present
$.user_id != null and $.transaction_id != null

# Complex assertions can be combined with logical operators
$.status == "success" and $.response_time < 500 and size_of($.items) > 0

Examples

Basic Assertions

# Assert all events have a valid user ID
$.user_id != null

# Assert numeric value is within expected range
$.amount > 0 and $.amount < 10000

# Assert event has required fields
$.timestamp != null and $.source != null and $.message != null

Complex Validations

# Data format validation
str_contains($.email, "@") and str_contains($.email, ".")

# Conditional validation using case expressions
case(
$.event_type == "payment" => $.amount != null and $.currency != null,
$.event_type == "registration" => $.email != null and $.username != null,
_ => true
)
  • eval: Transform events using the same expression language
  • filter: Drop events based on specific conditions using FEEL