Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting default evaluation value for a rule variable #52

Open
vikasverma93 opened this issue Mar 20, 2019 · 1 comment
Open

Setting default evaluation value for a rule variable #52

vikasverma93 opened this issue Mar 20, 2019 · 1 comment

Comments

@vikasverma93
Copy link

Right now we define rules like this. for this variable_1 should be there is in class variables or else at the time of evaluation it throws an error.

"rules": {
    	"conditions": { 
    		"all": [
    			{
    				"name": "variable_1",
    				"operator": "is_true",
    				"value": true
    			}
    		]
    	},
        "actions": [
    		{
    			"name": "action_1",
    			"params": {
    			}
    		}
    	]
}

My requirement is that is variable_1 is not there in class variables, either it should be ignored for evaluation or I should be able to pass a default value at the time of rules generation.

"rules": {
    	"conditions": { 
    		"all": [
    			{
    				"name": "variable_1",
    				"operator": "is_true",
    				"value": true,
                                "default": true
    			}
    		]
    	},
        "actions": [
    		{
    			"name": "action_1",
    			"params": {
    			}
    		}
    	]
}

Can some help me with this, how can I achieve this.

Thanks in advance

@bhargavrpatel
Copy link

Without changes in the engine logic via a PR that is possibly merged into the code base, you could possibly deal with the AssertionError. An alternative would be to change your variable class definition to dynamically introduce a method with the default value using __getattr__ .

This package assumes that a possible dashboard would only show the declared variables on the frontend via the exported ruleset JSON. I am wondering what business/product problem you are trying to solve. How is it possible to receive an undefined variable? There may be other alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants