ND.FW.RulesEngine
1.0.0
dotnet add package ND.FW.RulesEngine --version 1.0.0
NuGet\Install-Package ND.FW.RulesEngine -Version 1.0.0
<PackageReference Include="ND.FW.RulesEngine" Version="1.0.0" />
<PackageVersion Include="ND.FW.RulesEngine" Version="1.0.0" />
<PackageReference Include="ND.FW.RulesEngine" />
paket add ND.FW.RulesEngine --version 1.0.0
#r "nuget: ND.FW.RulesEngine, 1.0.0"
#:package ND.FW.RulesEngine@1.0.0
#addin nuget:?package=ND.FW.RulesEngine&version=1.0.0
#tool nuget:?package=ND.FW.RulesEngine&version=1.0.0
NdRulesEngine
A minimal, JSON-configurable rule engine built on top of Microsoft RulesEngine. Rules are pure config — no C# changes needed to add or change a rule.
Install
dotnet add package NdRulesEngine
Concepts
| Concept | Purpose |
|---|---|
| Workflow | A named group of rules, loaded from JSON |
| Rule | A single condition (Expression) evaluated against the input |
| Plugin | Fetches/enriches context data before rules run (no validation logic) |
| Custom Operator | A static C# method callable directly from an Expression |
Quick Start
var services = new ServiceCollection();
services.AddNdRulesEngine();
var provider = services.BuildServiceProvider();
var registry = provider.GetRequiredService<INdPluginRegistry>();
registry.ScanAssembly(typeof(Program).Assembly); // discovers [NdPlugin] classes
var engine = provider.GetRequiredService<INdRuleEngine>();
engine.LoadWorkflowFromJson(File.ReadAllText("rules.json"));
var input = new Dictionary<string, object?> { ["phone"] = "+919876543210", ["age"] = 10 };
var results = await engine.ExecuteAsync("CustomerValidation", input);
foreach (var r in results)
Console.WriteLine($"{r.RuleName}: {(r.IsSuccess ? "PASS" : $"FAIL - {r.ErrorMessage}")}");
Rule JSON
{
"WorkflowName": "CustomerValidation",
"Rules": [
{
"RuleName": "PhoneRequired",
"Expression": "input1[\"phone\"] != null && input1[\"phone\"].ToString() != \"\"",
"ErrorMessage": "Phone is required."
}
]
}
- Use bracket notation —
input1["field"]— not dot notation. RulesEngine compiles expressions statically and can't resolve dynamic dot-access at runtime. - Set
"Enabled": falseto disable a rule without deleting it.
Plugins (context enrichment)
Plugins run before evaluation to fetch or derive values — not to validate.
[NdPlugin("AgeLookupPlugin")]
public sealed class AgeLookupPlugin : INdContextPlugin
{
public Task EnrichAsync(IDictionary<string, object?> context, IDictionary<string, object?>? parameters, CancellationToken ct = default)
{
context["age"] = 25; // e.g. fetched from an external API
return Task.CompletedTask;
}
}
Attach it to a rule in JSON:
{
"RuleName": "AgeMinimum",
"Expression": "Convert.ToInt32(input1[\"age\"]) >= 18",
"ErrorMessage": "Age must be 18 or above.",
"Plugins": [{ "Name": "AgeLookupPlugin" }]
}
A rule can list multiple plugins; they run in order before the workflow evaluates.
Custom Operators
Any static class can be registered and called by name inside expressions.
public static class Operators
{
public static bool IsValidPan(object? value) =>
System.Text.RegularExpressions.Regex.IsMatch(value?.ToString() ?? "", "^[A-Z]{5}[0-9]{4}[A-Z]$");
}
services.AddNdRulesEngine(o => o.CustomOperatorTypes.Add(typeof(Operators)));
{ "RuleName": "PanFormat", "Expression": "Operators.IsValidPan(input1[\"pan\"])", "ErrorMessage": "Invalid PAN." }
Custom operator methods must take
object?parameters — RulesEngine passesExpandoObjectvalues asobject?.
API Surface
INdRuleEngine.LoadWorkflow(NdWorkflowDefinition)/.LoadWorkflowFromJson(string)INdRuleEngine.ExecuteAsync(workflowName, input)→IReadOnlyList<NdRuleResult>INdPluginRegistry.Register(name, plugin)/.ScanAssembly(assembly)NdRuleEngineOptions.CustomOperatorTypes— list of static classes to expose to expressions
License
Internal use.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- RulesEngine (>= 5.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 118 | 7/2/2026 |