jruizgit / rules

Durable Rules Engine
MIT License
1.14k stars 209 forks source link

Create Ruleset that has algebra function will not work? #393

Open tuongbuimtt opened 1 year ago

tuongbuimtt commented 1 year ago

I try to use some function that uses the algebra functions such as add(), sub(), mul(), ... And the result is cannot not creat the ruleset. How can I use that functions?

 whenAll: {
   m.number.sub(1) > 3;
  }
run:
{
    console.log(m);
 }

The output was:

TypeError: term(...).sub(...).gt is not a function
    at fn (eval at ruleset (/home/tuongmtt/Source/rule-engine/libjs/durable.js:1710:21), <anonymous>:11:119)
    at eval (eval at ruleset (/home/tuongmtt/Source/rule-engine/libjs/durable.js:1710:21), <anonymous>:23:12)
    at Object.ruleset (/home/tuongmtt/Source/rule-engine/libjs/durable.js:1710:21)
    at Object.<anonymous> (/home/tuongmtt/Source/rule-engine/testjs/test_operator_length.js:23:3)
    at Module._compile (node:internal/modules/cjs/loader:1165:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
    at Module.load (node:internal/modules/cjs/loader:1043:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47