Appveyor | NuGet | License |
---|---|---|
Desh is a concise and readable language to describe business rules.
Just install the Desh NuGet package:
PM> Install-Package desh
Craft a Desh document (YAML).
Let's take an example of an online travel agency. Customers want to know if they need a visa when traveling to another country.
The following Desh document describes business rules if a person needs a visa:
nationality:
- NL:
destination:
- US: electronic_online_visa
- UA:
days_of_stay:
- number_greater_than: 90
decide: paper_visa
- else: no_visa
- UA:
destination:
- US: paper_visa
- NL:
biometric_passport:
- yes: no_visa
- no: paper_visa
Then we need customer's data:
nationality: NL
destination: US
Then we can feed this to Desh engine.
var desh = @"
nationality:
- NL:
destination:
- US: electronic_online_visa
- UA:
days_of_stay:
- number_greater_than: 90
decide: paper_visa
- else: no_visa
- UA:
destination:
- US: paper_visa
- NL:
biometric_passport:
- yes: no_visa
- no: paper_visa
";
var customer =
new Dictionary<string, Func<Task<string>>>
{
{ "nationality", () => Task.FromResult("NL") },
{ "destination", () => Task.FromResult("US") }
};
var facade = new DeshFacade();
var visaDecision = await facade.ParseAndMakeStringDecision(desh, customer);
Console.WriteLine($"Visa requirement: {visaDecision}");
// outputs "Visa requirement: electronic_online_visa"
Desh is a phonetic abbreviation of Decision Expressions.