Rules Engine Overview | Regulus Documentation | Regulus

Rules Engine Overview

The Regulus Rule Engine allows you to define conditions for transactions and automatically flag any that match suspicious patterns. Use it to monitor transaction thresholds, currency rules, user IDs, and more.

1. Rule Structure

Each rule is composed of a field, an operator, and a value. When a transaction matches the condition, it is flagged.

{
  "rule_name": "High Value Transactions",
  "field": "amount",
  "operator": "GREATER_THAN",
  "value": "100000"
}

2. Supported Operators

The following operators can be used in rules:

  • GREATER_THAN – checks if the field is greater than the value
  • LESS_THAN – checks if the field is less than the value
  • GREATER_THAN_OR_EQUAL – checks if the field is greater than or equal to the value
  • LESS_THAN_OR_EQUAL – checks if the field is less than or equal to the value
  • EQUAL – checks if the field equals the value
  • NOT_EQUAL – checks if the field does not equal the value
  • IN – checks if the field is included in a list of values

3. Evaluating Transactions

Transactions are evaluated against all rules in your organization. If a transaction matches a rule, it is flagged and the matching rule name is returned.

const { evaluateTransaction } = require('regulus-rule-engine');

const transaction = {
  transaction_id: "txn_12345",
  user_id: "user_001",
  amount: 150000,
  currency: "USD",
  country: "US",
  timestamp: new Date().toISOString(),
};

const rules = [
  {
    id: 1,
    rule_name: "High Value Transactions",
    field: "amount",
    operator: "GREATER_THAN",
    value: "100000",
  },
];

const result = evaluateTransaction(transaction, rules);
console.log(result);
/*
{
  flagged: true,
  reasons: ["High Value Transactions"],
  matchedRules: [ { ...ruleObject } ]
}
*/

4. Error Handling

If a rule references a non-existent field or an invalid operator, the engine will throw a ValidationError. All errors are logged for debugging.

5. Managing Rules via API

You can manage rules using the /rules endpoints. Refer to the official API documentation for full details and examples:

Regulus Rules API Documentation

6. Logging & Monitoring

Audit logs ensure user accountability and help track rule changes over time, supporting compliance and internal monitoring.