Skip to main content

Installation

Get started by installing the package via npm, yarn, or pnpm:

Your First Rule

Let’s create and evaluate your first rule in just a few steps:
1

Import the library

2

Create engine and helpers

3

Define your data

4

Create and evaluate a rule

Congratulations! You just created and evaluated your first rule.

Building Complex Rules

Combining Multiple Conditions

Combine multiple conditions using logical operators to create powerful validation logic:

Working with Arrays

Check array membership and combine with other conditions:

Dynamic Field Comparison

Compare values from different parts of your data structure:

Common Patterns

Working with Different Data Types

Strings

Numbers

Arrays

Nested Objects

Configuration Options

Customize the engine behavior with configuration options:

Best Practices

Start Simple

Begin with simple rules and gradually build complexity. Test each component before combining.

Descriptive Names

Use clear, descriptive variable names that indicate the purpose of each rule.

Test Thoroughly

Test rules with various data scenarios including edge cases and invalid inputs.

Handle Missing Data

Always check for data existence before accessing nested properties.
Always validate user input before using it in rules to prevent security vulnerabilities and unexpected behavior.

Debugging Your Rules

Understanding rule evaluation results helps you debug issues quickly:
Test individual conditions separately before combining them to identify which specific condition is failing.

Next Steps

Core Concepts

Learn about the engine architecture and advanced features

Operators Reference

Explore all available operators and their usage

Performance Guide

Optimize your rules for maximum performance

Security Guide

Learn security best practices

Common Questions

Yes! Rules are JSON objects that can be easily stored and retrieved:
Absolutely! Rules work great for dynamic UI logic:
Follow these key practices: