This chapter covers the core features and capabilities of Conditional Logic Engine.
# Evaluate rules against form data
python src/conditional_logic_engine.py --rules examples/form_rules.json --data '{"country": "US", "age": "25"}'
# Run the built-in demo
python src/conditional_logic_engine.py --demoFollow this guide to get Conditional Logic Engine up and running in your environment.
| Flag | Description |
|---|---|
--rules FILE | JSON file containing conditional logic rules |
--data JSON | Form data as a JSON string to evaluate against |
--demo | Run a built-in demo showing all operator/action types |
{
"rules": [
{
"id": "show-company-field",
"description": "Show company name when role is Business",
"logic": "and",
"conditions": [
{
"field": "role",
"operator": "equals",
"value": "business"
}
],
"actions": [
{
"type": "show",
"target": "company_name"
},
{
"type": "require",
"target": "company_name"
}
]
},
{
"id": "skip-shipping-for-digital",
"logic": "or",
"conditions": [
{
"field": "product_type",
"operator": "equals",
"value": "digital"
},
{
"field": "product_type",
"operator": "equals",
"value": "subscription"
}
],
"actions": [
{
"type": "skip",
"target": "shipping_step"
}
]
}
]
}| Operator | Description | Example |
|---|---|---|
equals | Exact match (case-insensitive) | country equals "US" |
not_equals | Does not match | status not_equals "cancelled" |
greater_than | Numeric greater than | age greater_than 18 |
less_than | Numeric less than | quantity less_than 100 |
greater_equal | Numeric >= | total greater_equal 50 |
less_equal | Numeric <= | discount less_equal 25 |
contains | Substring match | email contains "@acme" |
not_contains | No substring match | name not_contains "test" |
starts_with | Prefix match | phone starts_with "+1" |
ends_with | Suffix match | email ends_with ".edu" |
is_empty | Field is blank | notes is_empty |
is_not_empty | Field has value | email is_not_empty |
matches | Regex pattern match | zip matches "^\d{5}$" |
in | Value in list | country in ["US","CA","UK"] |
not_in | Value not in list | role not_in ["admin","root"] |
| Action | Description |
|---|---|
show | Make a field/section visible |
hide | Hide a field/section |
require | Make a field required |
optional | Make a field optional |
skip | Skip a step/section |
set_value | Set a field's value |
validate | Apply a validation rule |
disable | Disable a field |
enable | Enable a field |
"logic": "and" — ALL conditions must be true (default)"logic": "or" — ANY condition must be trueGet the full Conditional Logic Engine and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.