---
title: Evaluate one rule
summary: Resolve a single rule's evaluation type and produce its output value, or null.
status: draft
owner: SAIF.Core Documentation Team
last_reviewed: 2026-09-24
library: SAIF.Services.ClaimInfoApi.Core
reference_type: package
operation_id: OP-CIA-02
trigger: Step 3 of OP-CIA-01, or a recursive call for an out-property child rule
---

# Evaluate one rule

This operation evaluates a single `NotificationRule` against the model, dispatching to an `int`, `bool`, or string evaluation path based on the rule's `TypeName` metadata, including the conditional recursion that lets a `bool` rule resolve to a derived property value.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CIA-02 |
| **Trigger** | Step 3 of [Calculate notifications for a model](op-cia-01-calculate-notifications.md), or a recursive call for an out-property child rule. |
| **Inputs** | `rule` (`NotificationRule`); `model` (`T`). |
| **Outputs** | A string value, or null. |
| **Primary components** | `NotificationRuleEngine.CalculateNotification<T>` (private) |
| **Entry point** | `Services/SAIF.Services.ClaimInfoApi.Core/NotificationRuleEngine.cs` (lines 34–71) |

## Steps

1. Resolve `rule.Type`, which is `Type.GetType(rule.TypeName)` ([CIA-BR-002](../business-rules.md#cia-br-002-evaluation-type-is-resolved-from-rule-metadata)).
   - If unresolvable, `rule.Type` is null and the rule falls through to the string branch (step 4).
2. When `rule.Type` is `int`: compile the rule as `Func<T,int>` via [Compile a rule into a delegate](op-cia-03-compile-rule.md), invoke it on the model, and return `.ToString()` of the result ([CIA-BR-003](../business-rules.md#cia-br-003-non-bool-rule-results-are-returned-as-strings)).
3. When `rule.Type` is `bool`: compile the rule as `Func<T,bool>` and invoke it.
   - If the result is true and `OutProperty` is set: build a child rule with `NotificationRule.PropertyRule(rule.Position, rule.OutPropertyTypeName, rule.Name, rule.OutProperty)`, copy the parent `Id` into the child's `_id`, and recursively evaluate it via this same operation. The child's value is returned ([CIA-BR-005](../business-rules.md#cia-br-005-a-true-bool-rule-with-an-out-property-recurses-into-a-child-property-rule)).
   - Else, if the result is true and `OutValue` is set: return `OutValue` ([CIA-BR-006](../business-rules.md#cia-br-006-a-true-bool-rule-without-an-out-property-falls-back-to-a-constant-out-value)).
   - If the result is true but neither `OutProperty` nor `OutValue` is set: return null.
   - If the result is false: return null ([CIA-BR-004](../business-rules.md#cia-br-004-a-false-bool-rule-produces-no-notification)).
4. Otherwise (any other resolved type, or an unresolvable `TypeName`): compile the rule as `Func<T,string>`, invoke it, and return its value ([CIA-BR-003](../business-rules.md#cia-br-003-non-bool-rule-results-are-returned-as-strings)).

## Process flow

The following diagram visualizes this operation's type-dispatch control flow.

```mermaid
flowchart TD
	Start([Trigger]) --> Resolve["Resolve rule.Type<br>from TypeName"]
	Resolve --> D{"Resolved type?"}
	D -->|int| IntPath["Compile Func&lt;T,int&gt;<br>return .ToString()"]
	D -->|bool| BoolPath["Compile Func&lt;T,bool&gt;<br>invoke delegate"]
	D -->|other / unresolvable| StrPath["Compile Func&lt;T,string&gt;<br>return value"]
	BoolPath --> BD{"Result true?"}
	BD -->|Yes, OutProperty set| Child["Recurse into child<br>PropertyRule (this operation)"]
	BD -->|Yes, OutValue only| OutVal(["Return OutValue"])
	BD -->|Yes, neither set| NullOut(["Return null"])
	BD -->|No| NullOut
	IntPath --> Done([Return string or null])
	StrPath --> Done
	Child --> Done
	OutVal --> Done
```

## Failure and edge-case behavior
- An unresolvable `TypeName` is not an error; the rule silently falls through to the string branch (step 4).
- A `bool` rule that is true with neither `OutProperty` nor `OutValue` set produces null, with no diagnostic.
- Compilation and invocation failures propagate from [Compile a rule into a delegate](op-cia-03-compile-rule.md) with no local `try`/`catch`.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Services/SAIF.Services.ClaimInfoApi.Core/NotificationRuleEngine.cs`
- `Services/SAIF.Services.ClaimInfoApi.Core/NotificationRule.cs`
