Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
travelgateXPublic archive

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

3 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Business Rules

Simple interface to create custom business rules that you can process on your code and check if pass or not

Example

import { Rule } from "core-businessrules";
import { RulesManager } from "core-businessrules";

export class TestRule implements Rule {
    public status: boolean;
    public code: string;
    public msg: string;
    private data: boolean;
    constructor(code: string, data: boolean) {
        this.code = code;
        this.data = data;
        this.status = true;
    }
    public process(): boolean {
        console.log("Processing " + this.code);
        if (!this.data){
            this.msg = "Fails rule";
            this.status = false;
        } else {
           this.msg = "Pass rule";
        }
        return this.status;
    }


}

var ruleObject = new TestRule();
var rm = RulesManager.get();

rm.addRule(ruleObject, "RuleGroupName");

var result = rm.process("RuleGroupName");

if (!result){
    console.log("FAILS");
} else {
    console.log("PASS");
}

for(var rule of rm.getAllRules("RuleGroupName")){
    console.log("******");
    console.log("Rule Name: " + rule.code);
    console.log("Rule status: " + rule.status.toString());
    console.log("Rule msg: " + rule.msg);
}

Run test

You can run the test

npm run start-test

Contributing

Refer to CONTRIBUTING.md

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages