1.0.7 • Published 5 years ago

@rajduandc/ruleengine v1.0.7

Weekly downloads
9
License
ISC
Repository
github
Last release
5 years ago

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

FeaturesDescription
On Demand ValidationValidate form on button click
Event Driven ValidationValidate item on different events of input elements such as focus out, onChange,etc
Skip LogicBased on rules it skip certain sections of form
State ManagementTo 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
1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago