@rajduandc/ruleengine

1.0.7 • Public • Published

Kantime Rule Engine

A library for custom validation in the form based on user defined json schema. It is not limited to validation but can perform different actions based on business rules.

Models

Features Description
On Demand Validation Validate form on button click
Event Driven Validation Validate item on different events of input elements such as focus out, onChange,etc
Skip Logic Based on rules it skip certain sections of form
State Management To show, hide, disable, enable and making read only certain sections of forms based on rules.

Installation

using npm :

$ npm i -g npm
$ npm i --save kantime-rule-engine

Usage

Initialize:

import {SkipRuleEngine, EventDrivenRuleEngine,FormStateRuleEngine,OnDemandRuleEngineExecution, EventBinding,SetInputData} from 'kantime-rule-engine';
 ComponentDidMount() {
    SkipRuleEngine();
    EventDrivenRuleEngine();
    FormStateRuleEngine();
    EventBinding();
    }

    render() {
    let EngineInputdata={};
     EngineInputdata= {...};  
 SetInputData(EngineInputdata,this.props.masterRules,this.props.formRules);
 // It is used to verify the data and check return values for defined rule
        
    }

Examples of user defined business rules

On Demand Validation

"Rule1" : {
        "Eval" : [ 
            "EQ", 
            "doc.student.name", 
            ""
        ],
        "actionData" : {
            "print" : {
                "message" : "Name can't be blank",
                "tgtEleInfo" : [ 
                    "Student.Name", 
                    "Name", 
                    "Name"
                ]
            }
        }
    }
Event Driven

             "Rule1" : {
                "Eval" : [ 
                    "NOTBETWEEN", 
                    "doc.student.age", 
                    "0,14"
                ],
                "actionData" : {
                    "Mandate" : {
                        "message" : [ 
                            "Age must be between 0 to 14 ", 
                            "warning"
                        ],
                        "event" : "focusout",
                        "srcEleInfo" : [ 
                            "Student.Age", 
                            "stu_age"
                        ]
                    }
                }
            },
Skip Logic

     "Rule1" : {
                "Eval" : [ 
                    "EQ", 
                    "doc.student.physicalDisorder", 
                    "No"
                ],
                "actionData" : {
                    "Skip" : {
                        "srcEleInfo" : [ 
                            "Student.PhysicalDisorder", 
                            "stu_disorder"
                        ],
                        "tgtEleInfo" : [ 
                            "Student.Identification", 
                            "stu_ident"
                        ],
                        "skipEleInfo" : [ 
                            "stu_disorderType", 
                            "stu_certificateNo"
                        ]
                    }
                }
            }
State Management

"Rule1" : {
                "Eval" : [ 
                    "EQ", 
                    "doc.student.status", 
                    "Qualified"
                ],
                "actionData" : {
                    "Hide" : [ 
                        "btn_delete", 
                        "btn_lock"
                    ],
                    "Show" : [ 
                        "btn_email", 
                        "btn_addToList", 
                        "btn_Save"
                    ]
                }
            },

Operators availaible for business rules

Operators
LENGTH
REGEX_MATCH
REGEX_NOT_MATCH
EQ
NEQ
GT
GTEQ
LT
LTEQ
OR
AND
IN
NOTIN
CONTAIN
NOTCONTAIN
SUBSTRING
NOTBETWEEN
DATEDIFF
HASDUPLICATE

Readme

Keywords

Package Sidebar

Install

npm i @rajduandc/ruleengine

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

171 kB

Total Files

16

Last publish

Collaborators

  • rajduandc