-
Notifications
You must be signed in to change notification settings - Fork 479
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
Complex rule for the fact #328
Comments
@suresh-webonise can you clarify the structure of the facts? Specifically the role, name, and sport. For example: const facts = {
id:1,
username:'sureshk',
student: {name:'zbc',percentage:100},
role: 'coach',
sport:'hockey'
}
const rule = {
condition: {
all: [
{
fact: 'id',
operator: 'equal'
value: 1
},
{
fact: 'username',
operator: 'equal',
value: 'sureshk'
},
{
fact: 'student',
path: '$.name',
operator: 'equal'
value: 'zbc'
},
...
]
}
} |
const fact={
id:1,
username:'sureshk',
student:[{name:'zbc',percentage:100},{name:'zb',percentage:10}],
role:['coach','mentor'],
sport:['hockey','base']
}
const rule = {
event: {
type: "",
params: {}
},
conditions: {
all: [
{
fact: "student",
operator: "customContains",
value: [
{
"field": "name",
"value": "zbc",
"operator": "="
},
{
"field": "percentage",
"value": 100,
"operator": "="
}
]
},
{
fact: "id",
operator: "equal",
value: 1
},
{
fact: "username",
operator: "equal",
value: "sureshk"
},
{
fact: "role",
operator: "contains",
value: "coach"
},
{
fact: "sport",
operator: "contains",
value: "hockey"
}
]
}
} I hadn't realized that students was an array of objects. In this case, I created a custom operator that searches for an object within an array. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suppose the fact is
const fact={
id:1,
username:'sureshk',
student:[{name:'zbc',percentage:100},{name:'zb',percentage:10}],
role:['coach','mentor'],
sport:['hockey','base']
}
and the rule should be
rule criteria => (student.name ='zbc' AND student.percentage=100) AND id=1 AND username='sureshk' AND role = 'coach' AND sport='hockey'
what will the json rules for the above rule criteria and facts
The text was updated successfully, but these errors were encountered: