Skip to content

briza-insurance/illogical


illogical Header

illogical

build status npm version install size zero dependencies npm downloads


JSON DSL for expressing and evaluating business rules. Underwriters use illogical to model business rules for their question sets, enabling distributors to render great user experiences.


This project is designed such that business rules can be shared between the front-end and back-end, serialized in JSON.

🚀 Get Started

# install illogical
npm install @briza/illogical
// Import the illogical engine
import Engine from '@briza/illogical'

// Create a new instance of the engine
const engine = new Engine()

// Data context
const ctx = {
  name: 'peter',
  age: 21,
  address: {
    city: 'Toronto',
    country: 'Canada',
  },
}

// Evaluate an expression in the given data context
engine.evaluate(['>', '$age', 20], ctx) // true

// Accessing a property
engine.evaluate(['==', '$address.city', 'Toronto'], ctx) // true

// Data Type Casting
engine.evaluate(['==', '$age.(String)', '21'], ctx) // true

// Evaluate a logical expression
engine.evaluate(['AND', ['>', '$age', 20], ['==', '$name', 'peter']]) // true

🖼️ Resources

Understand supported expressions:

Learn about usages:

Customize the engine and the documentation:

📖 Changelog

See changelog.md.

🤝 Contributing

See contributing.md.

📜 License

Illogical is released under the MIT license. See license.txt for details.

About

JSON DSL for expressing and evaluating business rules.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors