E-invoice rule engine · .NET NuGet
InvoiceLint.Core
Host a rule pack, call Validator.Validate, get rule IDs and locations. MIT. No Java at runtime.
Install
dotnet add package InvoiceLint.Core --version 0.1.0-dev.2
Targets net8.0 and net10.0. MIT license. No runtime package dependencies.
Quickstart
using System.Xml.Linq;
using InvoiceLint;
var result = Validator.Validate(xml, MyRulePack.Instance);
if (!result.IsValid)
{
foreach (var issue in result.Issues)
Console.WriteLine($"{issue.RuleId} {issue.Severity} {issue.Location}: {issue.Message}");
}
Rule pack
Implement IRulePack with an explicit Rules list and a RuleCatalog.
InvoiceLint.Core does not use runtime reflection. Load catalog JSON with RuleCatalogJson.Load.
public sealed class MyRulePack : IRulePack
{
public static MyRulePack Instance { get; } = new();
public string Id => "toy";
public RuleCatalog Catalog { get; } = new(
"toy", "1.0",
[new RuleCatalogEntry("toy-flag", "Shared", Severity.Fatal, "Flag must be ok.")]);
public IReadOnlyList<IValidationRule> Rules { get; } = [new ToyFlagRule()];
public bool Accepts(XElement root) => root.Name.LocalName == "Doc";
}
Validation
Inspect result.IsValid and result.Issues.
Engine IDs: IL-XML-001 (malformed XML), IL-XML-002 (unsupported root),
IL-RULE-001 (rule threw while isolation is on).
Related
- AeInvoice — UAE PINT AE pack on this engine
- InvoiceLint.Testing — catalog checks and mutations
License
MIT.
FAQ — InvoiceLint.Core
What is InvoiceLint.Core? +
InvoiceLint.Core is a native .NET rule engine for e-invoice XML. You supply an IRulePack; Validator.Validate runs the rules and returns rule IDs, severity, and locations. No Java, no Saxon, no remote calls.
How do I install InvoiceLint.Core? +
Run: dotnet add package InvoiceLint.Core --version 0.1.0-dev.2. The package targets .NET 8 and .NET 10 and is MIT licensed.
How do I write a rule pack? +
Implement IRulePack with an explicit Rules list and a RuleCatalog. Each IValidationRule.Evaluate uses RuleContext.Fail to emit issues. Load catalog JSON with RuleCatalogJson.Load.
Which products use InvoiceLint.Core? +
AeInvoice (UAE PINT AE) runs on this engine. InvoiceLint.Testing adds catalog checks and mutation helpers for pack tests.
Where is the NuGet package? +
https://www.nuget.org/packages/InvoiceLint.Core/ — install from nuget.org; public how-to lives on this page and the linked GitHub gist.